I'm looking for a way to generate XML like in the example below, but the existing XML libraries don't provide adequate documentation for me to understand how to use them to generate XML. I can find plenty of XML-generating libraries, but none with a simple example which says: here's how to generate this XML.
The Blaze and Lucid libraries are great for generating HTML, for example. Let's say you want to make this HTML:
<emph class="foo">bar</emph>
Using Lucid, you would write:
emph_ [class_ "foo"] "bar"
So what's a good way to do this with XML? I've been looking through the API documentation for, for instance, HaXml. But I can't find many tutorials about using those packages.
I did see that Yesod's Hamlet quasi-quoter is a very succinct way of generating XML. But I don't like the idea of quasi-quoting up a new schema, since it doesn't seem as maintable, and seems like learning a new language. So I'm hoping to find something more modular, and composable, like Blaze and Lucid.
Edit: To explain further, the problem is not a lack of Haskell XML libraries, or knowing which one to use. It's knowing how to use one (any of them) to generate XML. For instance, I know I can generate the HTML code <html>foo</html>
using Lucid's html_ "foo". But how can I do that for XML?
Here's a pseudo-Haskell example of what I'm trying to do:
Objective: generate the following XML:
<foo attribute="something">
<bar>
<foobar>
<barfoo>
something here
</barfoo>
</foobar>
</bar>
</foo>
Pseudo-Haskell:
foo_ [attribute_ "bar"] $ bar_ $ foobar_ $ barfoo_ "something here"