I have an XML file with a format similar to:
<root>
<baby>
<a>stuff</a>
<b>stuff</b>
<c>stuff</c>
</baby>
...
<baby>
<a>stuff</a>
<b>stuff</b>
<c>stuff</c>
</baby>
</root>
And the Clojure hash map is similar to:
{:a "More stuff" :b "Some other stuff" :c "Yet more of that stuff"}
And I would like to add the XML (¶) created from this hash map after the tag <root>, and before the first<baby>
(¶) The XML to add will look like this:
<baby>
<a>More stuff</a>
<b>Some other stuff</b>
<c>Yet more of that stuff</c>
</baby>
I would also like to delete the last file (or n ...) <baby>...</baby>from the file.
I am struggling to come up with idioms to add and add this data. I can do some crude string manipulation or parse the XML with xml / parse and xml-seq and then roll the nodes and (somehow?) Replace the data there, but it seems messy.
Any tips? Ideas? Advice? Pointers? They will be very grateful.
Thank!
source
share