I'm trying to generate an xml using boost. Going fine so far, but the xml that gets generated needs to have a namespace.
so instead of <name>"Harry"</name>
it would say <ns1:name>"Harry"</ns1:name>
Is there any way to add a namespace to the XML with boost without manually adding the "ns1" to every line?
So, I managed to get the result I wanted. Here's what I did:
My outer most element was called 'Document':
ptree& documentnode = pt.add("namespace1:Document", "");
then added tags to the element for each namespace:
pt.add("Document.<xmlattr>.xmlns:namespace1", "value");
Then in front of each element I'll have to add "namespace1":
documentnode.add("namespace1:name", "Harry");
output:
<namespace1:Document xmlns:namespace1=value>
<namespace1:name>Harry</namespace1:name>
</namespace1:Document>
Probably not the best solution, but it suits my needs.