comparison dep/pugixml/docs/samples/save_options.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 // default options; prints
13 // <?xml version="1.0"?>
14 // <foo bar="baz">
15 // <call>hey</call>
16 // </foo>
17 doc.save(std::cout);
18 std::cout << std::endl;
19
20 // default options with custom indentation string; prints
21 // <?xml version="1.0"?>
22 // <foo bar="baz">
23 // --<call>hey</call>
24 // </foo>
25 doc.save(std::cout, "--");
26 std::cout << std::endl;
27
28 // default options without indentation; prints
29 // <?xml version="1.0"?>
30 // <foo bar="baz">
31 // <call>hey</call>
32 // </foo>
33 doc.save(std::cout, "\t", pugi::format_default & ~pugi::format_indent); // can also pass "" instead of indentation string for the same effect
34 std::cout << std::endl;
35
36 // raw output; prints
37 // <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>
38 doc.save(std::cout, "\t", pugi::format_raw);
39 std::cout << std::endl << std::endl;
40
41 // raw output without declaration; prints
42 // <foo bar="baz"><call>hey</call></foo>
43 doc.save(std::cout, "\t", pugi::format_raw | pugi::format_no_declaration);
44 std::cout << std::endl;
45 // end::code[]
46 }
47
48 // vim:et