Mercurial > minori
comparison dep/pugixml/docs/samples/load_options.cpp @ 57:3c802806b74a
*: merge
| author | Paper <mrpapersonic@gmail.com> | 
|---|---|
| date | Thu, 28 Sep 2023 13:09:11 -0400 | 
| parents | d10b6c6b432e | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 56:6ff7aabeb9d7 | 57:3c802806b74a | 
|---|---|
| 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 | 
