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