comparison dep/pugixml/docs/samples/load_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 pugi::xml_document doc;
8
9 // tag::code[]
10 const char* source = "<!--comment--><node>&lt;</node>";
11
12 // Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded
13 doc.load_string(source);
14 std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
15
16 // Parsing with additional parse_comments option; comment node is now added to the tree
17 doc.load_string(source, pugi::parse_default | pugi::parse_comments);
18 std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
19
20 // Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded
21 doc.load_string(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes);
22 std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
23
24 // Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded
25 doc.load_string(source, pugi::parse_minimal);
26 std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
27 // end::code[]
28 }
29
30 // vim:et