rapidxml 节点加入另一个xml
void TestRapidXml()
{
char* xmlContent = new char[1024];
sprintf(xmlContent,"<root><head>aaa</head><body>bbb</body></root>");
xml_document<> xmlDoc;
xmlDoc.parse<0>(xmlContent);
char* xmlContent2 = new char[1024];
sprintf(xmlContent2,"<point x=\"1\" y =\"1\"/><point x=\"2\" y =\"2\"/>");
xml_document<> xmlDoc2;
xmlDoc2.parse<0>(xmlContent2);
xml_node<>* root = xmlDoc.first_node();
for(xml_node<>* node = xmlDoc2.first_node();node!=NULL;node=node->next_sibling())
{
// 注意:这里使用xmlDoc,是大的xml,不要使用xmlDoc2.
root->append_node(xmlDoc.clone_node(node));
}
string xmlStr = "";
rapidxml::print(std::back_inserter(xmlStr),xmlDoc,0);
delete []xmlContent;
delete []xmlContent2;
}