如何使用pugixml將現有的pugi::xml_node
追加到另一箇中? ,我知道的唯一功能是:使用pugixml將現有xml_node追加到另一個
pugi::xml_node node = root.append_child("child");
如何使用pugixml將現有的pugi::xml_node
追加到另一箇中? ,我知道的唯一功能是:使用pugixml將現有xml_node追加到另一個
pugi::xml_node node = root.append_child("child");
我發現這個方法,以及: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添加(現有的)節點或 /屬性。
您應該使用這裏描述的克隆功能:
http://pugixml.org/docs/manual.html#modify.clone
注意,克隆功能無法克隆整個文檔 - 也就是說,如果你有這是一個從這個數據加載的文件:
<node><child /></node>
那麼如果你想克隆這個數據到<子節點>節點,你應該這樣做:
doc.child("node").child("child").append_copy(doc.child("node"));
這將產生以下文件:
<node><child><node><child /></node></child></node>
我用的第一個,但它給我一個錯誤 – 2013-04-04 18:31:55
嘗試xml_node xml_node :: insert_child_after(xml_node_type類型,常量xml_node和節點),請 - 它似乎與追加 – duDE 2013-04-04 18:32:37
相同是什麼意思xml_type? – 2013-04-04 18:33:51