I am using RapidXML to modify an existing XML doc. This is my code:
file<> xmlFile( launchFullPath.c_str() );
xml_document<> doc;
doc.parse<0>(xmlFile.data());
// create a node called basedir
xml_node<> *basedir = doc.allocate_node(node_element, "basedir");
// append basedir to the launch
xml_node<> *node = doc.first_node("launch");
node->append_node(basedir);
// append attribute to basedir
xml_attribute<> *attr = doc.allocate_attribute("path", SUMOfullDirectory.c_str());
basedir->append_attribute(attr);
Eventually, the content of the XML will be:
<launch>
<copy file="hello.net.xml"/>
<copy file="hello.rou.xml"/>
<copy file="hello.loopDetector.xml"/>
<copy file="hello.obstacles.xml"/>
<copy file="hello.sumo.cfg" type="config"/>
<basedir path="/home/mani/Desktop/VENTOS/sumo/Incident_Detection"/>
<seed value="0"/>
</launch>
At the end, I want to convert the content of the XML doc into string. As you can see (from the debug mode in eclipse IDE) the content of the XML file is not properly stored into st variable. I used the RapidXML::print method as well, and the result is the same. What can be wrong here?