comparison dep/pugixml/docs/samples/save_declaration.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 // tag::code[]
8 // get a test document
9 pugi::xml_document doc;
10 doc.load_string("<foo bar='baz'><call>hey</call></foo>");
11
12 // add a custom declaration node
13 pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
14 decl.append_attribute("version") = "1.0";
15 decl.append_attribute("encoding") = "UTF-8";
16 decl.append_attribute("standalone") = "no";
17
18 // <?xml version="1.0" encoding="UTF-8" standalone="no"?>
19 // <foo bar="baz">
20 // <call>hey</call>
21 // </foo>
22 doc.save(std::cout);
23 std::cout << std::endl;
24 // end::code[]
25 }
26
27 // vim:et