I’ve used boost serialization but this doesn’t appear to allow me to generate xml that conforms to a particular schema — it seems it’s purpose was to just to persist a class’s state.
Platform: linux
What do you guys use to generate NOT parse xml?
So far I’m going down Foredecker’s route of just generating it myself — it’s not a large document but I really shouldn’t be having this much trouble finding a decent library to generate it correctly.
As for boost, the things that I would like to be able to do is set the node names, set attributes in my nodes, and get rid of all the extra crap that comes with it as I don’t really care about having to put my document back into that class.
Some may declare me an XML heretic – but one effective way is to just generate it with your favorite string output tools (print, output streams, etc) – this can go to a buffer or a file.
Once saved – you really should then validate with a schema before committing it our shipping it off.
For one of our projects we have a very simple set of templates for managing begin/end tags and attributes. These each have a stream output operator. This makes it very easy to generate the source XML and debug. This makes the structure of the XML generation code look very much like the XML itself.
One advantage of this is that you can generate large amounts of XML efficiently if streaming to a file. You will pay the validation costs later (presumably at a better time for an expensive operation).
The downside of this technique is that it is essentially output only. It is not suitable for creating then consuming XML dynamically.