Construye un árbol xml desde cero - pugixml C ++

En primer lugar, me gustaría decir que he estado usando un analizador XML escrito por Frank Vanden Berghen y recientemente he intentado migrar a Pugixml. Estoy encontrando la transición un poco difícil. Con la esperanza de obtener alguna ayuda aquí.

Pregunta: ¿Cómo puedo crear un árbol desde cero para el pequeño xml a continuación utilizando las API de pugixml? Intenté buscar en los ejemplos en la página de inicio de pugixml, pero la mayoría de ellos están codificados con valores de nodo raíz. lo que quiero decir es

if (!doc.load("<node id='123'>text</node><!-- comment -->", pugi::parse_default | pugi::parse_comments)) return -1;

está codificado También intenté leer sobre la documentación xml_document y xml_node pero no pude averiguar cómo empezar si tengo que construir un árbol desde cero.

#include "pugixml.hpp"

#include <string.h>
#include <iostream>

int main()
{
    pugi::xml_document doc;
    if (!doc.load("<node id='123'>text</node><!-- comment -->", pugi::parse_default | pugi::parse_comments)) return -1;

    //[code_modify_base_node
    pugi::xml_node node = doc.child("node");

    // change node name
    std::cout << node.set_name("notnode");
    std::cout << ", new node name: " << node.name() << std::endl;

    // change comment text
    std::cout << doc.last_child().set_value("useless comment");
    std::cout << ", new comment text: " << doc.last_child().value() << std::endl;

    // we can't change value of the element or name of the comment
    std::cout << node.set_value("1") << ", " << doc.last_child().set_name("2") << std::endl;
    //]

    //[code_modify_base_attr
    pugi::xml_attribute attr = node.attribute("id");

    // change attribute name/value
    std::cout << attr.set_name("key") << ", " << attr.set_value("345");
    std::cout << ", new attribute: " << attr.name() << "=" << attr.value() << std::endl;

    // we can use numbers or booleans
    attr.set_value(1.234);
    std::cout << "new attribute value: " << attr.value() << std::endl;

    // we can also use assignment operators for more concise code
    attr = true;
    std::cout << "final attribute value: " << attr.value() << std::endl;
    //]
}

// vim:et
XML:
<?xml version="1.0" encoding="UTF-8"?>
<d:testrequest xmlns:d="DAV:" xmlns:o="urn:example.com:testdrive">
   <d:basicsearch>
      <d:select>
         <d:prop>
            <o:versionnumber/>
            <d:creationdate />
         </d:prop>
      </d:select>
      <d:from>
         <d:scope>
            <d:href>/</d:href>
            <d:depth>infinity</d:depth>
         </d:scope>
      </d:from>
      <d:where>
         <d:like>
            <d:prop>
               <o:name />
            </d:prop>
            <d:literal>%img%</d:literal>
         </d:like>
      </d:where>
    </d:basicsearch>
</d:testrequest>

Pude ver la mayoría de los ejemplos publicados sobre cómo leer / analizar el xml, pero no pude encontrar cómo crear uno desde cero.

Respuestas a la pregunta(2)

Su respuesta a la pregunta