Haskell語言學習筆記(92)HXT

HXT

The Haskell XML Toolbox (hxt) 是一個解析 XML 的庫。html

$ 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 Haskellpost

相關文章
相關標籤/搜索