XML Serialization/Deserialization in C++

30,149

Solution 1

I notice that each TiXmlBase Class has a Print method and also supports streaming to strings and streams.

You could walk the new parts of the document in sequence and output those parts as they are added, maybe?

Give it a try.....

Tony

Solution 2

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.

Solution 3

Here is a better example of C++ object serialization:

http://www.codeproject.com/KB/XML/XMLFoundation.aspx

Share:
30,149
Lily
Author by

Lily

A cheerful team player, a thinker and dreamer, a workaholic practitioner.

Updated on November 20, 2020

Comments

  • Lily
    Lily over 3 years

    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.