Mercurial > minori
comparison dep/pugixml/docs/samples/modify_remove.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 if (!doc.load_string("<node><description>Simple node</description><param name='id' value='123'/></node>")) return -1; | |
9 | |
10 // tag::code[] | |
11 // remove description node with the whole subtree | |
12 pugi::xml_node node = doc.child("node"); | |
13 node.remove_child("description"); | |
14 | |
15 // remove id attribute | |
16 pugi::xml_node param = node.child("param"); | |
17 param.remove_attribute("value"); | |
18 | |
19 // we can also remove nodes/attributes by handles | |
20 pugi::xml_attribute id = param.attribute("name"); | |
21 param.remove_attribute(id); | |
22 // end::code[] | |
23 | |
24 doc.print(std::cout); | |
25 } | |
26 | |
27 // vim:et |