Search code examples
c++xmlpugixml

C++ pugiXML, Append a child before the first child in a node


How do you append a new child to a node and place it prior to the first child? i.e. I want to try and append a new child and push it to the top in order.

Say, if I have:

pugi::xml_node root; 
pugi::xml_node level1 = root.append_child("Level1");
pugi::xml_node level2 = root.append_child("Level2");
pugi::xml_node level3 = root.append_child("Level3");

Can I somehow append a new node, level4 and have it before the level1 node in the XML tree?


Solution

  • Someone just showed me to do prepend_child instead. Still thanks Galik for the suggestion though.