comparison dep/pugixml/docs/samples/modify_add.cpp @ 367:8d45d892be88 default tip

*: instead of pugixml, use Qt XML features this means we have one extra Qt dependency though...
author Paper <paper@tflc.us>
date Sun, 17 Nov 2024 22:55:47 -0500
parents 886f66775f31
children
comparison
equal deleted inserted replaced
366:886f66775f31 367:8d45d892be88
1 #include "pugixml.hpp"
2
3 #include <iostream>
4
5 int main()
6 {
7 pugi::xml_document doc;
8
9 // tag::code[]
10 // add node with some name
11 pugi::xml_node node = doc.append_child("node");
12
13 // add description node with text child
14 pugi::xml_node descr = node.append_child("description");
15 descr.append_child(pugi::node_pcdata).set_value("Simple node");
16
17 // add param node before the description
18 pugi::xml_node param = node.insert_child_before("param", descr);
19
20 // add attributes to param node
21 param.append_attribute("name") = "version";
22 param.append_attribute("value") = 1.1;
23 param.insert_attribute_after("type", param.attribute("name")) = "float";
24 // end::code[]
25
26 doc.print(std::cout);
27 }
28
29 // vim:et