Mercurial > minori
comparison dep/pugixml/docs/samples/modify_add.cpp @ 55:d10b6c6b432e
add xml lib, we will need to use it eventually
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 26 Sep 2023 12:37:08 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
54:466ac9870df9 | 55:d10b6c6b432e |
---|---|
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 |