我有一个XML文档,我需要使用pugixml和Cpp编写。我的XML文档的一部分如下所示:
line 4 <people>
line 5 <guys>
line 6 <dude name="man" delay="1" life="0.75" score="5" />
line 7 <dude name="man" delay="1" life="0.75" score="5" />
line 8 <dude name="man" delay="1" life="0.75" score="5" />
line 9 <dude name="man" delay="1" life="0.75" score="5" />
line 10 <dude name="man" delay="1" life="0.75" score="5" />
line 11 </guys>
line 12 <guys>
line 13 <dude name="man" delay="1" life="0.75" score="5" />
line 14 <dude name="man" delay="1" life="0.75" score="5" />
line 15 <dude name="man" delay="1" life="0.75" score="5" />
line 16 <dude name="man" delay="1" life="0.75" score="5" />
line 17 <dude name="man" delay="1" life="0.75" score="5" />
line 18 </guys>
</people>
我如何在第13行之后添加另一个(dude name =“man”delay =“1”life =“0.75”score =“5”),在我的.xml文件中将所有其他行向下移动一行?< / p>
我正在努力....
//get xml object
pugi::xml_document doc;
//load xml file
doc.load_file(pathToFile.c_str);
//edit file
doc.child("people").child("guys").append_copy(doc.child("people").child("guys").child("dude"));
//save file
doc.save_file(pathToFile.c_str);
但它似乎没有起作用。有什么想法吗?