XML Serialization/Deserialization in C++

Lily picture Lily · Sep 4, 2009 · Viewed 29.2k times · Source

I am using C++ from Mingw, which is the windows version of GNC C++.

What I want to do is: serialize C++ object into an XML file and deserialize object from XML file on the fly. I check TinyXML. It's pretty useful, and (please correct me if I misunderstand it) it basically add all the nodes during processing, and finally put them into a file in one chunk using TixmlDocument::saveToFile(filename) function.

I am working on real-time processing, and how can I write to a file on the fly and append the following result to the file?

Thanks.

Answer

TimW picture TimW · Sep 4, 2009

BOOST has a very nice Serialization/Deserialization lib BOOST.Serialization.
If you stream your objects to a boost xml archive it will stream them in xml format. If xml is to big or to slow you only need to change the archive in a text or binary archive to change the streaming format.