Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. {-# LANGUAGE OverloadedStrings #-}
  2.  
  3. module Main where
  4.  
  5. import qualified Data.Map as Map
  6. import Data.Text (Text)
  7. import qualified Data.Text.Lazy as Lazy
  8. import Text.XML
  9. import Text.XML.Cursor (child, content, fromDocument)
  10.  
  11. main :: IO ()
  12. main = do
  13. let pprinted = renderText renderSettings document
  14. putStr . Lazy.unpack $ pprinted
  15. let root = either undefined fromDocument $ parseText def pprinted
  16. print . head $ child root >>= content
  17. where
  18. renderSettings = def { rsPretty = True }
  19.  
  20. document :: Document
  21. document = Document (Prologue [] Nothing []) root []
  22. where
  23. root = simpleElem "foo" [NodeContent "bar"]
  24.  
  25. simpleElem :: Text -> [Node] -> Element
  26. simpleElem name = Element (simpleName name) Map.empty
  27.  
  28. simpleName :: Text -> Name
  29. simpleName n = Name n Nothing Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement