Mercurial > minori
comparison dep/pugixml/docs/samples/load_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 pugi::xml_document doc; | |
8 | |
9 // tag::code[] | |
10 const char* source = "<!--comment--><node><</node>"; | |
11 | |
12 // Parsing with default options; note that comment node is not added to the tree, and entity reference < 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; < 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 < 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 |