std::string src = "<xml><node1>aaa</node1><node2>bbb</node2><node1>ccc</node1></xml>";
std::string src2 = "<nodex>xxx</nodex>";
I want to append the node in src2 inside the tree in src using RapidXml I do this:
xml_document<> xmldoc;
xml_document<> xmlseg;
std::vector<char> s(src.begin(), src.end());
std::vector<char> x(src2.begin(), src2.end());
xmldoc.parse<0>(&s[0]);
xmlseg.parse<0>(&x[0]);
xml_node<>* a = xmlseg.first_node(); /* Node to append */
xmldoc.first_node("xml")->append_node(a); /* Appending node a to the tree in src */
Well, great it compiles, but when running I got this horrible error:
void rapidxml::xml_node::append_node(rapidxml::xml_node*) [with Ch = char]: Assertion `child && !child->parent() && child->type() != node_document' failed. Aborted
I don't know how to do. The problem is simple I need to append a node to a tree (xml) but I have strings.
I guess this happens because I'm trying to insert a node of a tree into another tree... only nodes allocated for a given tree can be added to that tree... this sucks...
Is there a way I can do what I need in a simple way?
Thank you.