xml2json- translate xml to json

Safe HaskellNone




Element type and operations

data Element Source

represent a XML element.




elAttrs :: [(Text, Text)]

tag attributes.

elValues :: [Text]

text values.

elChildren :: [(Text, Element)]

child elements.


addChild' :: (Text, Element) -> Element -> ElementSource

add a child element to an element

addValue' :: Text -> Element -> ElementSource

add a text value to an element

addAttr' :: (Text, Text) -> Element -> ElementSource

add an attribute to an element

addAttrs' :: [(Text, Text)] -> Element -> ElementSource

add multiple attributes to an element

Stack type and operations

type Stack = [(Text, Element)]Source

xml element stack with recent opened element at the top.

popStack :: Stack -> StackSource

close current tag.

closeStack :: Stack -> ElementSource

close all unclosed tags and return the root element.

Builder type and operations

type Builder = State Stack ()Source

Builder is a State monad to transform a Stack.

runBuilder :: Builder -> ElementSource

exec the state monad and close the result stack.

beginElement :: Text -> BuilderSource

open element

endElement :: BuilderSource

close element

modifyTopElement :: (Element -> Element) -> BuilderSource

util to modify top element.

addChild :: (Text, Element) -> BuilderSource

add child element to top element.

addValue :: Text -> BuilderSource

add value to top element.

addAttr :: (Text, Text) -> BuilderSource

add attribute to top element.

addAttrs :: [(Text, Text)] -> BuilderSource

add multiple attributes to top element.