3

如何pugi::xml_node使用 pugixml 将现有附加到另一个?我知道的唯一功能是:

pugi::xml_node node = root.append_child("child");
4

2 回答 2

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>
于 2013-04-05T18:14:25.183 回答
1

我也找到了这种方法: 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 和 insert_child_before 在指定节点/属性之前或之后添加(现有)节点。

于 2013-04-04T18:25:59.733 回答