diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-06-30 14:29:44 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-06-30 14:29:44 +0000 |
commit | 69a3d9be05e6cd1e664c099927b9588e96bd790b (patch) | |
tree | 2802ec7dd2273ff60880bb2eda7cfa68e5a28f9d /docs/samples/load_options.cpp | |
parent | 678d2f2369a58d6db9a7bb9e732ce2589086961a (diff) |
docs: Added load_options sample
git-svn-id: http://pugixml.googlecode.com/svn/trunk@554 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'docs/samples/load_options.cpp')
-rw-r--r-- | docs/samples/load_options.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/samples/load_options.cpp b/docs/samples/load_options.cpp new file mode 100644 index 0000000..82273aa --- /dev/null +++ b/docs/samples/load_options.cpp @@ -0,0 +1,28 @@ +#include "pugixml.hpp"
+
+#include <iostream>
+
+int main()
+{
+ pugi::xml_document doc;
+
+//[code_load_options
+ const char* source = "<!--comment--><node><</node>";
+
+ // Parsing with default options; note that comment node is not added to the tree, and entity reference < is expanded
+ doc.load(source);
+ std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
+
+ // Parsing with additional parse_comments option; comment node is now added to the tree
+ doc.load(source, pugi::parse_default | pugi::parse_comments);
+ std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
+
+ // Parsing with additional parse_comments option and without the (default) parse_escapes option; < is not expanded
+ doc.load(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes);
+ std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
+
+ // Parsing with minimal option mask; comment node is not added to the tree, and < is not expanded
+ doc.load(source, pugi::parse_minimal);
+ std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
+//]
+}
|