3

How to append an exsiting pugi::xml_node into another one using pugixml ? the only function that i know is :

pugi::xml_node node = root.append_child("child");
vonbrand
  • 10,026
  • 8
  • 27
  • 47
Mouhamed Fakarovic
  • 231
  • 1
  • 4
  • 10

2 Answers2

4

You should use cloning functions described here:

http://pugixml.org/docs/manual.html#modify.clone

Note that cloning functions can't clone the entire document - i.e. if you have a document that's loaded from this data:

<node><child /></node>

Then if you want to clone this data into <child> node, you should do:

doc.child("node").child("child").append_copy(doc.child("node"));

This will yield the following document:

<node><child><node><child /></node></child></node>
Community
  • 1
  • 1
zeuxcg
  • 8,703
  • 1
  • 22
  • 33
1

I have found this methods as well: http://pugixml.googlecode.com/svn/tags/release-0.9/docs/manual/modify.html

xml_node xml_node::append_child(xml_node_type type = node_element);
xml_node xml_node::insert_child_after(xml_node_type type, const xml_node& node);
xml_node xml_node::insert_child_before(xml_node_type type, const xml_node& node);

insert_child_after and insert_child_before add the (existing) node before or after specified node/attribute.

Leo Chapiro
  • 12,996
  • 7
  • 53
  • 84