I'm a Haskell beginner. I'm using xml-conduit to transform some XML into HTML, as seen in the Yesod tutorial. I have some attributes and some content that I want to make into a node to add it to existing XML. What's the best way to create a Node? I've tried calling Node
, but it says it's not in scope. I can make a node using NodeContent "content"
, or using NodeElement (Element ... )
, but how can I create a node, providing both elements and content?
(The Yesod book suggests using Hamlet, but I'd rather not involve Hamlet, since I'm already using Blaze, and don't want to have to learn and maintain too many templating languages.)
Here are the constructors and fields for Node
...
data Node
= NodeElement Element
| NodeInstruction Instruction
| NodeContent Text
| NodeComment Text
... and Element
:
data Element = Element
{ elementName :: Name
, elementAttributes :: Map.Map Name Text
, elementNodes :: [Node]
}
Note that an Element
holds a list of Node
s, and so you can make it hold a NodeContent
:
NodeElement $ Element "b" empty [ NodeContent "Title" ]
(Cf. this example in the linked tutorial.)