Mercurial > minori
comparison dep/pugixml/docs/samples/modify_remove.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 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 |