HXT
The Haskell XML Toolbox (hxt) 是一个解析 XML 的库。
$ cabal install hxt
Installed hxt-9.3.1.16
Prelude> :m +Text.XML.HXT.Parser.XmlParsec
Prelude Text.XML.HXT.Parser.XmlParsec>
Prelude Text.XML.HXT.Parser.XmlParsec> xread "<foo>abc<bar/>def</foo>"
[NTree (XTag "foo" []) [NTree (XText "abc") [],NTree (XTag "bar" []) [],NTree (XText "def") []]]
Prelude Text.XML.HXT.Parser.XmlParsec> :m +Text.XML.HXT.DOM.FormatXmlTree
Prelude Text.XML.HXT.Parser.XmlParsec Text.XML.HXT.DOM.FormatXmlTree> putStrLn $ formatXmlTree $ head $ xread "<foo>abc<bar/>def</foo>"
---XTag "foo"
|
+---XText "abc"
|
+---XTag "bar"
|
+---XText "def"
参考链接
Haskell/XML - Wikibooks
HXT - HaskellWiki
HXT Arrow Lessons
XML Processing with Error checking
Working With Html In Haskell