2, pugixml additional node, the insertion property

xml files are: nodes, attributes, attribute values

    pugi::xml_document doc;

    // additional node Node 
    Pugi :: = Node xml_node doc.append_child ( " Node " );

    // child node attached nodes description, node value of the Simple 
    Pugi xml_node descr :: = node.append_child ( " Description " );
    descr.append_child(pugi::node_pcdata).set_value("Simple node");

    // additional node child nodes param, before the description 
    Pugi :: xml_node param = node.insert_child_before ( " param " , descr);

    // additional attributes, node param 
    param.append_attribute ( " name " ) = " Version " ;
    param.append_attribute("value") = 1.1;
    param.insert_attribute_after ( " type " , param.attribute ( " name " )) = " a float " ; // the attribute name attribute type insert

    // print the results 
    doc.print (std :: cout);

 

Guess you like

Origin www.cnblogs.com/xixixing/p/12123035.html