I need to change some values of an existing XML using Code Synthesis in c++.
For example i have this:
<person>
<name>"Paul"</name>
</person>
Now i need to change it to "Chris".
I have used several time Code Synthesis for parsing but never to write into a XML.
p.s Yes i've compiled my XSD with "Generate Serialization" option.
Thank you
The C++ class that was generated out of the schema type for the person element probably has a member function for setting the name:
void name(const ::xml_schema::string& s);
You would then be able to change the name to Chris like this:
person.name("Chris");
You could find more information in the C++/Tree Mapping Getting Started Guide. See the chapter 2.5: Adding Serialization.
There is also a small code example that reads in an XML file into the Codesynthesis data model, then modifies some values, and finally serializes it to back to XML. See the library example.