source: icGREP/icgrep-devel/icgrep/combine/pugixml/docs/samples/save_options.cpp @ 5516

Last change on this file since 5516 was 5516, checked in by faldebey, 21 months ago

added combinatorial testing tool

File size: 1.3 KB
Line 
1#include "pugixml.hpp"
2
3#include <iostream>
4
5int 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
Note: See TracBrowser for help on using the repository browser.