
i am having a problem with hxt, i was wondering if anyone here has experience with it. in particular, i find that the xread function chokes on xml files with xml declarations, and i am not sure why. consider this sample script: module Main where import Text.XML.HXT.Parser main = do xml <- getContents print $ head $ xread xml and this file content (test.xml): <?xml version="1.0"?> <foo><bar>BAR1</bar><bar>BAR2</bar></foo> running: $ runhaskell hxt.hs < test.xml NTree (XError 2 "\"string: \"<?xml version=\\\"1.0\\\"?>\\n<foo><bar>BAR1

brad clawsie wrote:
i am having a problem with hxt, i was wondering if anyone here has experience with it. in particular, i find that the xread function chokes on xml files with xml declarations, and i am not sure why. [...]
This is intended. Generally, wherever the HXT manual says "content" (e.g., the description of xread says "with the XML content parser"), it means the (one and only) top level element, i.e., the <foo>...</foo>. To parse a complete XML file, look for a parser that says "document", which means the whole thing, e.g., parseXmlDocument. main = do xml <- getContents print $ head $ parseXmlDocument "test.xml" xml
participants (2)
-
Albert Y. C. Lai
-
brad clawsie