Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverloadedStrings #-}
- module Main where
- import qualified Data.Map as Map
- import Data.Text (Text)
- import qualified Data.Text.Lazy as Lazy
- import Text.XML
- import Text.XML.Cursor (child, content, fromDocument)
- main :: IO ()
- main = do
- let pprinted = renderText renderSettings document
- putStr . Lazy.unpack $ pprinted
- let root = either undefined fromDocument $ parseText def pprinted
- print . head $ child root >>= content
- where
- renderSettings = def { rsPretty = True }
- document :: Document
- document = Document (Prologue [] Nothing []) root []
- where
- root = simpleElem "foo" [NodeContent "bar"]
- simpleElem :: Text -> [Node] -> Element
- simpleElem name = Element (simpleName name) Map.empty
- simpleName :: Text -> Name
- simpleName n = Name n Nothing Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement