Search code examples
c++xmlrapidxml

Cloning rapidxml::xml_document


How do I get a complete copy of a RapidXML xml_document?

There is a clone_node function; how to use to to create a complete copy of an existing document?


Solution

  • I'm sure there's a cleaner, tree-based approach, but I solved it with the following, where str is the xml output from another doc:

    xml_document<> doc;
    doc.parse<0>(doc.allocate_string(str));