summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jamfile.jam6
-rw-r--r--Makefile21
-rw-r--r--README.md6
-rw-r--r--docs/config.adoc7
-rw-r--r--docs/images/caution.pngbin426 -> 0 bytes
-rw-r--r--docs/images/dom_tree_thumb.pngbin3127 -> 0 bytes
-rw-r--r--docs/images/home.pngbin217 -> 0 bytes
-rw-r--r--docs/images/next.pngbin204 -> 0 bytes
-rw-r--r--docs/images/note.pngbin357 -> 0 bytes
-rw-r--r--docs/images/prev.pngbin198 -> 0 bytes
-rw-r--r--docs/images/up.pngbin224 -> 0 bytes
-rw-r--r--docs/images/vs2005_link1_thumb.pngbin2531 -> 0 bytes
-rw-r--r--docs/images/vs2005_link2_thumb.pngbin1901 -> 0 bytes
-rw-r--r--docs/images/vs2005_pch1_thumb.pngbin4511 -> 0 bytes
-rw-r--r--docs/images/vs2005_pch2_thumb.pngbin1579 -> 0 bytes
-rw-r--r--docs/images/vs2005_pch3_thumb.pngbin1944 -> 0 bytes
-rw-r--r--docs/images/vs2005_pch4_thumb.pngbin1632 -> 0 bytes
-rw-r--r--docs/images/vs2010_link1_thumb.pngbin1765 -> 0 bytes
-rw-r--r--docs/images/vs2010_link2_thumb.pngbin1820 -> 0 bytes
-rw-r--r--docs/manual.adoc2929
-rw-r--r--docs/manual.html5713
-rw-r--r--docs/manual.qbk2771
-rw-r--r--docs/manual.xsl118
-rw-r--r--docs/manual/access.html900
-rw-r--r--docs/manual/apiref.html1664
-rw-r--r--docs/manual/changes.html1064
-rw-r--r--docs/manual/dom.html732
-rw-r--r--docs/manual/install.html517
-rw-r--r--docs/manual/loading.html914
-rw-r--r--docs/manual/modify.html758
-rw-r--r--docs/manual/saving.html543
-rw-r--r--docs/manual/toc.html163
-rw-r--r--docs/manual/xpath.html749
-rw-r--r--docs/pugixml.css598
-rw-r--r--docs/quickstart.adoc (renamed from docs/quickstart.qbk)278
-rw-r--r--docs/quickstart.html1933
-rw-r--r--docs/quickstart.xsl8
-rw-r--r--docs/samples/custom_memory_management.cpp8
-rw-r--r--docs/samples/include.cpp4
-rw-r--r--docs/samples/load_error_handling.cpp6
-rw-r--r--docs/samples/load_file.cpp4
-rw-r--r--docs/samples/load_memory.cpp25
-rw-r--r--docs/samples/load_options.cpp4
-rw-r--r--docs/samples/load_stream.cpp4
-rw-r--r--docs/samples/modify_add.cpp4
-rw-r--r--docs/samples/modify_base.cpp8
-rw-r--r--docs/samples/modify_remove.cpp4
-rw-r--r--docs/samples/save_custom_writer.cpp4
-rw-r--r--docs/samples/save_declaration.cpp54
-rw-r--r--docs/samples/save_file.cpp4
-rw-r--r--docs/samples/save_options.cpp4
-rw-r--r--docs/samples/save_stream.cpp4
-rw-r--r--docs/samples/save_subtree.cpp4
-rw-r--r--docs/samples/text.cpp70
-rw-r--r--docs/samples/traverse_base.cpp12
-rw-r--r--docs/samples/traverse_iter.cpp4
-rw-r--r--docs/samples/traverse_predicate.cpp8
-rw-r--r--docs/samples/traverse_rangefor.cpp64
-rw-r--r--docs/samples/traverse_walker.cpp8
-rw-r--r--docs/samples/xpath_error.cpp4
-rw-r--r--docs/samples/xpath_query.cpp4
-rw-r--r--docs/samples/xpath_select.cpp4
-rw-r--r--docs/samples/xpath_variables.cpp76
-rw-r--r--readme.txt6
-rw-r--r--scripts/CMakeLists.txt2
-rw-r--r--src/pugiconfig.hpp6
-rw-r--r--src/pugixml.cpp130
-rw-r--r--src/pugixml.hpp8
-rw-r--r--tests/allocator.cpp24
-rw-r--r--tests/archive.pl3
-rw-r--r--tests/data/truncation.xml16
-rw-r--r--tests/test_document.cpp6
-rw-r--r--tests/test_dom_modify.cpp66
-rw-r--r--tests/test_header_only.cpp3
-rw-r--r--tests/test_version.cpp2
-rw-r--r--tests/test_write.cpp55
-rw-r--r--tests/writer_string.cpp6
77 files changed, 10097 insertions, 13027 deletions
diff --git a/Jamfile.jam b/Jamfile.jam
index 512e2c9..e140f35 100644
--- a/Jamfile.jam
+++ b/Jamfile.jam
@@ -88,7 +88,9 @@ for CONFIG in $(CONFIGURATIONS)
# build tests
local TESTS = $(CFGBUILD)/tests.exe ;
- Application $(TESTS) : [ Glob tests : *.cpp ] : $(CFGFLAGS) : $(PUGIXML) ;
+ local TEST_SOURCES = [ Glob tests : *.cpp ] ;
+ TEST_SOURCES -= [ Glob tests : fuzz_*.cpp ] ;
+ Application $(TESTS) : $(TEST_SOURCES) : $(CFGFLAGS) : $(PUGIXML) ;
Alias tests : $(TESTS) ;
# run tests
@@ -144,7 +146,7 @@ for SAMPLE in [ Glob docs/samples : *.cpp ]
}
# release
-VERSION = 1.5 ;
+VERSION = 1.6 ;
RELEASE_FILES =
[ Glob contrib : *.cpp *.hpp ]
[ Glob src : *.cpp *.hpp ]
diff --git a/Makefile b/Makefile
index b50ff69..0e64129 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,17 @@
+.SUFFIXES:
+MAKEFLAGS+=-r
+
config=debug
defines=standard
BUILD=build/make-$(CXX)-$(config)-$(defines)
-SOURCES=src/pugixml.cpp tests/main.cpp tests/allocator.cpp tests/test.cpp tests/writer_string.cpp $(wildcard tests/test_*.cpp)
+SOURCES=src/pugixml.cpp $(filter-out tests/fuzz_%,$(wildcard tests/*.cpp))
EXECUTABLE=$(BUILD)/test
+VERSION=$(shell sed -n 's/.*version \(.*\).*/\1/p' src/pugiconfig.hpp)
+RELEASE=$(shell git ls-files src docs/*.html docs/*.css docs/samples docs/images scripts contrib readme.txt)
+
CXXFLAGS=-g -Wall -Wextra -Werror -pedantic
LDFLAGS=
@@ -47,6 +53,13 @@ fuzz:
clean:
rm -rf $(BUILD)
+release: build/pugixml-$(VERSION).tar.gz build/pugixml-$(VERSION).zip
+
+docs: docs/quickstart.html docs/manual.html
+
+build/pugixml-%: .FORCE | $(RELEASE)
+ perl tests/archive.pl $@ $|
+
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
@@ -56,4 +69,8 @@ $(BUILD)/%.o: %
-include $(OBJECTS:.o=.d)
-.PHONY: all test clean
+.SECONDEXPANSION:
+docs/%.html: docs/%.adoc $$(shell sed -n 's/include\:\:\(.*\)\[.*/docs\/\1/p' docs/%.adoc)
+ asciidoctor -b html5 -a version=$(VERSION) $< -o $@
+
+.PHONY: all test clean release .FORCE
diff --git a/README.md b/README.md
index 71eaede..bce5be8 100644
--- a/README.md
+++ b/README.md
@@ -12,15 +12,15 @@ pugixml is used by a lot of projects, both open-source and proprietary, for perf
Documentation for the current release of pugixml is available on-line as two separate documents:
-* [Quick-start guide](http://cdn.rawgit.com/zeux/pugixml/v1.5/docs/quickstart.html), that aims to provide enough information to start using the library;
-* [Complete reference manual](http://cdn.rawgit.com/zeux/pugixml/v1.5/docs/manual.html), that describes all features of the library in detail.
+* [Quick-start guide](http://pugixml.org/docs/quickstart.html), that aims to provide enough information to start using the library;
+* [Complete reference manual](http://pugixml.org/docs/manual.html), that describes all features of the library in detail.
You’re advised to start with the quick-start guide; however, many important library features are either not described in it at all or only mentioned briefly; if you require more information you should read the complete manual.
## License
This library is available to anybody free of charge, under the terms of MIT License:
-Copyright (c) 2006-2014 Arseny Kapoulkine
+Copyright (c) 2006-2015 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
diff --git a/docs/config.adoc b/docs/config.adoc
new file mode 100644
index 0000000..0d4f48d
--- /dev/null
+++ b/docs/config.adoc
@@ -0,0 +1,7 @@
+website <http://pugixml.org>; repository <http://github.com/zeux/pugixml>
+:toc: right
+:source-highlighter: pygments
+:source-language: c++
+:sectanchors:
+:sectlinks:
+:imagesdir: images \ No newline at end of file
diff --git a/docs/images/caution.png b/docs/images/caution.png
deleted file mode 100644
index 5adc377..0000000
--- a/docs/images/caution.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/dom_tree_thumb.png b/docs/images/dom_tree_thumb.png
deleted file mode 100644
index 8b0ba85..0000000
--- a/docs/images/dom_tree_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/home.png b/docs/images/home.png
deleted file mode 100644
index 124a56b..0000000
--- a/docs/images/home.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/next.png b/docs/images/next.png
deleted file mode 100644
index fbb2fdc..0000000
--- a/docs/images/next.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/note.png b/docs/images/note.png
deleted file mode 100644
index e960b39..0000000
--- a/docs/images/note.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/prev.png b/docs/images/prev.png
deleted file mode 100644
index ceadada..0000000
--- a/docs/images/prev.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/up.png b/docs/images/up.png
deleted file mode 100644
index 23e4aec..0000000
--- a/docs/images/up.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2005_link1_thumb.png b/docs/images/vs2005_link1_thumb.png
deleted file mode 100644
index 86882e0..0000000
--- a/docs/images/vs2005_link1_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2005_link2_thumb.png b/docs/images/vs2005_link2_thumb.png
deleted file mode 100644
index 64954d5..0000000
--- a/docs/images/vs2005_link2_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2005_pch1_thumb.png b/docs/images/vs2005_pch1_thumb.png
deleted file mode 100644
index 96df958..0000000
--- a/docs/images/vs2005_pch1_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2005_pch2_thumb.png b/docs/images/vs2005_pch2_thumb.png
deleted file mode 100644
index 9d443b1..0000000
--- a/docs/images/vs2005_pch2_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2005_pch3_thumb.png b/docs/images/vs2005_pch3_thumb.png
deleted file mode 100644
index 60fa8f8..0000000
--- a/docs/images/vs2005_pch3_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2005_pch4_thumb.png b/docs/images/vs2005_pch4_thumb.png
deleted file mode 100644
index 3b6e53c..0000000
--- a/docs/images/vs2005_pch4_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2010_link1_thumb.png b/docs/images/vs2010_link1_thumb.png
deleted file mode 100644
index 223b429..0000000
--- a/docs/images/vs2010_link1_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/images/vs2010_link2_thumb.png b/docs/images/vs2010_link2_thumb.png
deleted file mode 100644
index 34d9dd9..0000000
--- a/docs/images/vs2010_link2_thumb.png
+++ /dev/null
Binary files differ
diff --git a/docs/manual.adoc b/docs/manual.adoc
new file mode 100644
index 0000000..bab2f80
--- /dev/null
+++ b/docs/manual.adoc
@@ -0,0 +1,2929 @@
+= pugixml {version} manual
+include::config.adoc[]
+:numbered:
+
+[[overview]]
+== Overview
+
+[[overview.introduction]]
+=== Introduction
+
+http://pugixml.org/[pugixml] is a light-weight C{plus}{plus} XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an <<xpath,XPath 1.0 implementation>> for complex data-driven tree queries. Full Unicode support is also available, with <<dom.unicode,two Unicode interface variants>> and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is <<install.portability,extremely portable>> and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the <<overview.license,MIT license>>, making it completely free to use in both open-source and proprietary applications.
+
+pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can't process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD or XML Schema validation, the library is not for you.
+
+This is the complete manual for pugixml, which describes all features of the library in detail. If you want to start writing code as quickly as possible, you are advised to link:quickstart.html[read the quick start guide first].
+
+NOTE: No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to https://github.com/zeux/pugixml/issues/new[submit an issue or open a pull request] with a fix.
+
+[[overview.feedback]]
+=== Feedback
+
+If you believe you've found a bug in pugixml (bugs include compilation problems (errors/warnings), crashes, performance degradation and incorrect behavior), please file an issue via https://github.com/zeux/pugixml/issues/new[issue submission form]. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc.
+
+Feature requests can be reported the same way as bugs, so if you're missing some functionality in pugixml or if the API is rough in some places and you can suggest an improvement, https://github.com/zeux/pugixml/issues/new[file an issue]. However please note that there are many factors when considering API changes (compatibility with previous versions, API redundancy, etc.), so generally features that can be implemented via a small function without pugixml modification are not accepted. However, all rules have exceptions.
+
+If you have a contribution to pugixml, such as build script for some build system/IDE, or a well-designed set of helper functions, or a binding to some language other than C{plus}{plus}, please https://github.com/zeux/pugixml/issues/new[file an issue or open a pull request]. Your contribution has to be distributed under the terms of a license that's compatible with pugixml license; i.e. GPL/LGPL licensed code is not accepted.
+
+If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: arseny.kapoulkine@gmail.com.
+
+[[overview.thanks]]
+=== Acknowledgments
+
+pugixml could not be developed without the help from many people; some of them are listed in this section. If you've played a part in pugixml development and you can not find yourself on this list, I'm truly sorry; please <<email,send me an e-mail>> so I can fix this.
+
+Thanks to *Kristen Wegner* for pugxml parser, which was used as a basis for pugixml.
+
+Thanks to *Neville Franks* for contributions to pugxml parser.
+
+Thanks to *Artyom Palvelev* for suggesting a lazy gap contraction approach.
+
+Thanks to *Vyacheslav Egorov* for documentation proofreading.
+
+[[overview.license]]
+=== License
+
+The pugixml library is distributed under the MIT license:
+
+....
+Copyright (c) 2006-2015 Arseny Kapoulkine
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+....
+
+This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
+
+....
+This software is based on pugixml library (http://pugixml.org).
+pugixml is Copyright (C) 2006-2015 Arseny Kapoulkine.
+....
+
+[[install]]
+== Installation
+
+[[install.getting]]
+=== Getting pugixml
+
+pugixml is distributed in source form. You can either download a source distribution or clone the Git repository.
+
+[[install.getting.source]]
+==== Source distributions
+
+You can download the latest source distribution as an archive:
+
+https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.zip[pugixml-{version}.zip] (Windows line endings)
+/
+https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.tar.gz[pugixml-{version}.tar.gz] (Unix line endings)
+
+The distribution contains library source, documentation (the manual you're reading now and the quick start guide) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.
+
+If you need an older version, you can download it from the https://github.com/zeux/pugixml/releases[version archive].
+
+[[install.getting.git]]
+==== Git repository
+
+The Git repository is located at https://github.com/zeux/pugixml/. There is a Git tag "v\{version\}" for each version; also there is the "latest" tag, which always points to the latest stable release.
+
+For example, to checkout the current version, you can use this command:
+
+[source,bash,subs="attributes"]
+----
+git clone https://github.com/zeux/pugixml
+cd pugixml
+git checkout v{version}
+----
+
+The repository contains library source, documentation, code examples and full unit test suite.
+
+Use `latest` tag if you want to automatically get new versions. Use other tags if you want to switch to new versions only explicitly. Also please note that the master branch contains the work-in-progress version of the code; while this means that you can get new features and bug fixes from master without waiting for a new release, this also means that occasionally the code can be broken in some configurations.
+
+[[install.getting.subversion]]
+==== Subversion repository
+
+You can access the Git repository via Subversion using https://github.com/zeux/pugixml URL. For example, to checkout the current version, you can use this command:
+
+[source,bash,subs="attributes"]
+----
+svn checkout https://github.com/zeux/pugixml/tags/v{version} pugixml
+----
+
+[[install.building]]
+=== Building pugixml
+
+pugixml is distributed in source form without any pre-built binaries; you have to build them yourself.
+
+The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions; `pugiconfig.hpp` is a supplementary configuration file (see <<install.building.config>>). The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
+
+[[install.building.embed]]
+==== Building pugixml as a part of another static library/executable
+
+The easiest way to build pugixml is to compile the source file, `pugixml.cpp`, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio footnote:[All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just add `pugixml.cpp` to one of your projects.
+
+If you're using Microsoft Visual Studio and the project has precompiled headers turned on, you'll see the following error messages:
+
+----
+pugixml.cpp(3477) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
+----
+
+The correct way to resolve this is to disable precompiled headers for `pugixml.cpp`; you have to set "Create/Use Precompiled Header" option (Properties dialog -> C/C{plus}{plus} -> Precompiled Headers -> Create/Use Precompiled Header) to "Not Using Precompiled Headers". You'll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option):
+
+[cols="4*a",frame=none]
+|===
+| image::vs2005_pch1.png[link="images/vs2005_pch1.png"]
+| image::vs2005_pch2.png[link="images/vs2005_pch2.png"]
+| image::vs2005_pch3.png[link="images/vs2005_pch3.png"]
+| image::vs2005_pch4.png[link="images/vs2005_pch4.png"]
+|===
+
+[[install.building.static]]
+==== Building pugixml as a standalone static library
+
+It's possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010+, and configuration scripts for CMake and premake4. You're welcome to submit project files/build scripts for other software; see <<overview.feedback>>.
+
+There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like `pugixml_vs2008.vcproj`, and another one for statically linked CRT, which has a name like `pugixml_vs2008_static.vcproj`. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. `pugixml_vs2008.vcproj` for Microsoft Visual Studio 2008).
+
+In addition to adding pugixml project to your workspace, you'll have to make sure that your application links with pugixml library. If you're using Microsoft Visual Studio 2005/2008, you can add a dependency from your application project to pugixml one. If you're using Microsoft Visual Studio 2010+, you'll have to add a reference to your application project instead. For other IDEs/systems, consult the relevant documentation.
+
+[cols="4*a",frame=none,options=header]
+|===
+2+| Microsoft Visual Studio 2005/2008
+2+| Microsoft Visual Studio 2010+
+| image::vs2005_link1.png[link="images/vs2005_link1.png"]
+| image::vs2005_link2.png[link="images/vs2005_link2.png"]
+| image::vs2010_link1.png[link="images/vs2010_link1.png"]
+| image::vs2010_link2.png[link="images/vs2010_link2.png"]
+|===
+
+[[install.building.shared]]
+==== Building pugixml as a standalone shared library
+
+It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining <<PUGIXML_API,PUGIXML_API>> macro, i.e. via `pugiconfig.hpp`:
+
+[source]
+----
+#ifdef _DLL
+ #define PUGIXML_API __declspec(dllexport)
+#else
+ #define PUGIXML_API __declspec(dllimport)
+#endif
+----
+
+CAUTION: If you're using STL-related functions, you should use the shared runtime library to ensure that a single heap is used for STL allocations in your application and in pugixml; in MSVC, this means selecting the 'Multithreaded DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (`/MD` or `/MDd` linker switch). You should also make sure that your runtime library choice is consistent between different projects.
+
+[[install.building.header]]
+==== Using pugixml in header-only mode
+
+[[PUGIXML_HEADER_ONLY]]
+It's possible to use pugixml in header-only mode. This means that all source code for pugixml will be included in every translation unit that includes `pugixml.hpp`. This is how most of Boost and STL libraries work.
+
+Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using <<PUGIXML_NO_XPATH,PUGIXML_NO_XPATH>> define to improve compilation time.
+
+To enable header-only mode, you have to define `PUGIXML_HEADER_ONLY`. You can either do it in `pugiconfig.hpp`, or provide them via compiler command-line.
+
+Note that it is safe to compile `pugixml.cpp` if `PUGIXML_HEADER_ONLY` is defined - so if you want to i.e. use header-only mode only in Release configuration, you
+can include pugixml.cpp in your project (see <<install.building.embed>>), and conditionally enable header-only mode in `pugiconfig.hpp` like this:
+
+[source]
+----
+#ifndef _DEBUG
+ #define PUGIXML_HEADER_ONLY
+#endif
+----
+
+[[install.building.config]]
+==== Additional configuration options
+
+pugixml uses several defines to control the compilation process. There are two ways to define them: either put the needed definitions to `pugiconfig.hpp` (it has some examples that are commented out) or provide them via compiler command-line. Consistency is important: the definitions should match in all source files that include `pugixml.hpp` (including pugixml sources) throughout the application. Adding defines to `pugiconfig.hpp` lets you guarantee this, unless your macro definition is wrapped in preprocessor `#if`/`#ifdef` directive and this directive is not consistent. `pugiconfig.hpp` will never contain anything but comments, which means that when upgrading to a new version, you can safely leave your modified version intact.
+
+[[PUGIXML_WCHAR_MODE]]`PUGIXML_WCHAR_MODE` define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use `char` as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on `wchar_t` size, most functions use `wchar_t` as character type). See <<dom.unicode>> for more details.
+
+[[PUGIXML_NO_XPATH]]`PUGIXML_NO_XPATH` define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space.
+
+[[PUGIXML_NO_STL]]`PUGIXML_NO_STL` define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation.
+
+[[PUGIXML_NO_EXCEPTIONS]]`PUGIXML_NO_EXCEPTIONS` define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities.
+
+[[PUGIXML_API]]`PUGIXML_API`, [[PUGIXML_CLASS]]`PUGIXML_CLASS` and [[PUGIXML_FUNCTION]]`PUGIXML_FUNCTION` defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of `PUGIXML_CLASS` or `PUGIXML_FUNCTION` definitions, `PUGIXML_API` definition is used instead. For example, to specify fixed calling convention, you can define `PUGIXML_FUNCTION` to i.e. `__fastcall`. Another example is DLL import/export attributes in MSVC (see <<install.building.shared>>).
+
+NOTE: In that example `PUGIXML_API` is inconsistent between several source files; this is an exception to the consistency rule.
+
+[[PUGIXML_MEMORY_PAGE_SIZE]]`PUGIXML_MEMORY_PAGE_SIZE`, [[PUGIXML_MEMORY_OUTPUT_STACK]]`PUGIXML_MEMORY_OUTPUT_STACK` and [[PUGIXML_MEMORY_XPATH_PAGE_SIZE]]`PUGIXML_MEMORY_XPATH_PAGE_SIZE` can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <<dom.memory.tuning>>.
+
+[[PUGIXML_HAS_LONG_LONG]]`PUGIXML_HAS_LONG_LONG` define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C{plus}{plus}11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually.
+
+[[install.portability]]
+=== Portability
+
+pugixml is written in standard-compliant C{plus}{plus} with some compiler-specific workarounds where appropriate. pugixml is compatible with the C{plus}{plus}11 standard, but does not require C{plus}{plus}11 support. Each version is tested with a unit test suite (with code coverage about 99%) on the following platforms:
+
+* Microsoft Windows:
+** Borland C{plus}{plus} Compiler 5.82
+** Digital Mars C{plus}{plus} Compiler 8.51
+** Intel C{plus}{plus} Compiler 8.0, 9.0 x86/x64, 10.0 x86/x64, 11.0 x86/x64
+** Metrowerks CodeWarrior 8.0
+** Microsoft Visual C{plus}{plus} 6.0, 7.0 (2002), 7.1 (2003), 8.0 (2005) x86/x64, 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 (2011) x86/x64/ARM, 12.0 (2013) x86/x64/ARM and some CLR versions
+** MinGW (GCC) 3.4, 4.4, 4.5, 4.6 x64
+
+* Linux (GCC 4.4.3 x86/x64, GCC 4.8.1 x64, Clang 3.2 x64)
+* FreeBSD (GCC 4.2.1 x86/x64)
+* Apple MacOSX (GCC 4.0.1 x86/x64/PowerPC, Clang 3.5 x64)
+* Sun Solaris (sunCC x86/x64)
+* Microsoft Xbox 360
+* Nintendo Wii (Metrowerks CodeWarrior 4.1)
+* Sony Playstation Portable (GCC 3.4.2)
+* Sony Playstation 3 (GCC 4.1.1, SNC 310.1)
+* Various portable platforms (Android NDK, BlackBerry NDK, Samsung bada, Windows CE)
+
+[[dom]]
+== Document object model
+
+pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from a character stream (file, string, C{plus}{plus} I/O stream), then traversed with the special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C{plus}{plus} I/O stream or custom transport).
+
+[[dom.tree]]
+=== Tree structure
+
+The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C{plus}{plus} type <<xml_document,xml_document>>. Document has one or more child nodes, which correspond to C{plus}{plus} type <<xml_node,xml_node>>. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C{plus}{plus} type <<xml_attribute,xml_attribute>>, and some additional data (i.e. name).
+
+[[xml_node_type]]
+The tree nodes can be of one of the following types (which together form the enumeration `xml_node_type`):
+
+* Document node ([[node_document]]`node_document`) - this is the root of the tree, which consists of several child nodes. This node corresponds to <<xml_document,xml_document>> class; note that <<xml_document,xml_document>> is a sub-class of <<xml_node,xml_node>>, so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation.
+
+* Element/tag node ([[node_element]]`node_element`) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:
++
+----
+<node attr="value"><child/></node>
+----
++
+There are two element nodes here: one has name `"node"`, single attribute `"attr"` and single child `"child"`, another has name `"child"` and does not have any attributes or child nodes.
+
+* Plain character data nodes ([[node_pcdata]]`node_pcdata`) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:
++
+----
+<node> text1 <child/> text2 </node>
+----
++
+Here `"node"` element has three children, two of which are PCDATA nodes with values `" text1 "` and `" text2 "`.
+
+* Character data nodes ([[node_cdata]]`node_cdata`) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA:
++
+----
+<node> <![CDATA[[text1]]> <child/> <![CDATA[[text2]]> </node>
+----
++
+CDATA nodes make it easy to include non-escaped `<`, `&` and `>` characters in plain text. CDATA value can not contain the character sequence `]]>`, since it is used to determine the end of node contents.
+
+* Comment nodes ([[node_comment]]`node_comment`) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows:
++
+----
+<!-- comment text -->
+----
++
+Here the comment node has value `"comment text"`. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_comments,parse_comments>> flag.
+
+* Processing instruction node ([[node_pi]]`node_pi`) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows:
++
+----
+<?name value?>
+----
++
+Here the name (also called PI target) is `"name"`, and the value is `"value"`. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_pi,parse_pi>> flag.
+
+* Declaration node ([[node_declaration]]`node_declaration`) represents document declarations in XML. Declaration nodes have a name (`"xml"`) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:
++
+----
+<?xml version="1.0"?>
+----
++
+Here the node has name `"xml"` and a single attribute with name `"version"` and value `"1.0"`. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_declaration,parse_declaration>> flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with <<format_no_declaration,format_no_declaration>> flag.
+
+* Document type declaration node ([[node_doctype]]`node_doctype`) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like `<!ENTITY>`. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:
++
+----
+<!DOCTYPE greeting [ <!ELEMENT greeting (#PCDATA)> ]>
+----
++
+Here the node has value `"greeting [ <!ELEMENT greeting (#PCDATA)> ]"`. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <<parse_doctype,parse_doctype>> flag.
+
+Finally, here is a complete example of XML document and the corresponding tree representation (link:samples/tree.xml[]):
+
+[cols="2*a",frame=none]
+|===
+|
+[source,xml]
+----
+<?xml version="1.0"?>
+<mesh name="mesh_root">
+ <!-- here is a mesh node -->
+ some text
+ <![CDATA[someothertext]]>
+ some more text
+ <node attr1="value1" attr2="value2" />
+ <node attr1="value2">
+ <innernode/>
+ </node>
+</mesh>
+<?include somedata?>
+----
+|
+image::dom_tree.png[link="images/dom_tree.png"]
+|===
+
+[[dom.cpp]]
+=== C{plus}{plus} interface
+
+NOTE: All pugixml classes and functions are located in the `pugi` namespace; you have to either use explicit name qualification (i.e. `pugi::xml_node`), or to gain access to relevant symbols via `using` directive (i.e. `using pugi::xml_node;` or `using namespace pugi;`). The namespace will be omitted from all declarations in this documentation hereafter; all code examples will use fully qualified names.
+
+Despite the fact that there are several node types, there are only three C{plus}{plus} classes representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. The classes are described below.
+
+[[xml_document]][[xml_document::document_element]]
+`xml_document` is the owner of the entire document structure; it is a non-copyable class. The interface of `xml_document` consists of loading functions (see <<loading>>), saving functions (see <<saving>>) and the entire interface of `xml_node`, which allows for document inspection and/or modification. Note that while `xml_document` is a sub-class of `xml_node`, `xml_node` is not a polymorphic type; the inheritance is present only to simplify usage. Alternatively you can use the `document_element` function to get the element node that's the immediate child of the document.
+
+[[xml_document::ctor]][[xml_document::dtor]][[xml_document::reset]]
+Default constructor of `xml_document` initializes the document to the tree with only a root node (document node). You can then populate it with data using either tree modification functions or loading functions; all loading functions destroy the previous tree with all occupied memory, which puts existing node/attribute handles for this document to invalid state. If you want to destroy the previous tree, you can use the `xml_document::reset` function; it destroys the tree and replaces it with either an empty one or a copy of the specified document. Destructor of `xml_document` also destroys the tree, thus the lifetime of the document object should exceed the lifetimes of any node/attribute handles that point to the tree.
+
+CAUTION: While technically node/attribute handles can be alive when the tree they're referring to is destroyed, calling any member function for these handles results in undefined behavior. Thus it is recommended to make sure that the document is destroyed only after all references to its nodes/attributes are destroyed.
+
+[[xml_node]][[xml_node::type]]
+`xml_node` is the handle to document node; it can point to any node in the document, including the document node itself. There is a common interface for nodes of all types; the actual <<xml_node_type,node type>> can be queried via the `xml_node::type()` method. Note that `xml_node` is only a handle to the actual node, not the node itself - you can have several `xml_node` handles pointing to the same underlying object. Destroying `xml_node` handle does not destroy the node and does not remove it from the tree. The size of `xml_node` is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return `xml_node` objects by value without additional overhead.
+
+[[node_null]]
+There is a special value of `xml_node` type, known as null node or empty node (such nodes have type `node_null`). It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don't do anything and return empty nodes/attributes or empty strings as their result (see documentation for specific functions for more detailed information). This is useful for chaining calls; i.e. you can get the grandparent of a node like so: `node.parent().parent()`; if a node is a null node or it does not have a parent, the first `parent()` call returns null node; the second `parent()` call then also returns null node, which makes error handling easier.
+
+[[xml_attribute]]
+`xml_attribute` is the handle to an XML attribute; it has the same semantics as `xml_node`, i.e. there can be several `xml_attribute` handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.
+
+[[xml_attribute::ctor]][[xml_node::ctor]]
+Both `xml_node` and `xml_attribute` have the default constructor which initializes them to null objects.
+
+[[xml_attribute::comparison]][[xml_node::comparison]]
+`xml_node` and `xml_attribute` try to behave like pointers, that is, they can be compared with other objects of the same type, making it possible to use them as keys in associative containers. All handles to the same underlying object are equal, and any two handles to different underlying objects are not equal. Null handles only compare as equal to themselves. The result of relational comparison can not be reliably determined from the order of nodes in file or in any other way. Do not use relational comparison operators except for search optimization (i.e. associative container keys).
+
+[[xml_attribute::hash_value]][[xml_node::hash_value]]
+If you want to use `xml_node` or `xml_attribute` objects as keys in hash-based associative containers, you can use the `hash_value` member functions. They return the hash values that are guaranteed to be the same for all handles to the same underlying object. The hash value for null handles is 0.
+
+[[xml_attribute::unspecified_bool_type]][[xml_node::unspecified_bool_type]][[xml_attribute::empty]][[xml_node::empty]]
+Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node/attribute is empty with the following code: `if (node) { ... }` or `if (!node) { ... } else { ... }`. Alternatively you can check if a given `xml_node`/`xml_attribute` handle is null by calling the following methods:
+
+[source]
+----
+bool xml_attribute::empty() const;
+bool xml_node::empty() const;
+----
+
+Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling <<xml_node::remove_child,xml_node::remove_child>>) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.
+
+[[dom.unicode]]
+=== Unicode interface
+
+There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via <<PUGIXML_WCHAR_MODE,PUGIXML_WCHAR_MODE>> define; you can set it via `pugiconfig.hpp` or via preprocessor options, as discussed in <<install.building.config>>. If this define is set, the wchar_t interface is used; otherwise (by default) the char interface is used. The exact wide character encoding is assumed to be either UTF-16 or UTF-32 and is determined based on the size of `wchar_t` type.
+
+NOTE: If the size of `wchar_t` is 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some characters are represented as two code points.
+
+All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode:
+
+[source]
+----
+const char* xml_node::name() const;
+bool xml_node::set_name(const char* value);
+----
+
+and like this in wchar_t mode:
+
+[source]
+----
+const wchar_t* xml_node::name() const;
+bool xml_node::set_name(const wchar_t* value);
+----
+
+[[char_t]][[string_t]]
+There is a special type, `pugi::char_t`, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type `pugi::string_t`, which is defined as the STL string of the character type; it corresponds to `std::string` in char mode and to `std::wstring` in wchar_t mode.
+
+In addition to the interface, the internal implementation changes to store XML data as `pugi::char_t`; this means that these two modes have different memory usage characteristics. The conversion to `pugi::char_t` upon document loading and from `pugi::char_t` upon document saving happen automatically, which also carries minor performance penalty. The general advice however is to select the character mode based on usage scenario, i.e. if UTF-8 is inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice.
+
+[[as_utf8]][[as_wide]]
+There are cases when you'll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes:
+
+[source]
+----
+std::string as_utf8(const wchar_t* str);
+std::wstring as_wide(const char* str);
+----
+
+Both functions accept a null-terminated string as an argument `str`, and return the converted string. `as_utf8` performs conversion from UTF-16/32 to UTF-8; `as_wide` performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. `str` has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument:
+
+[source]
+----
+std::string as_utf8(const std::wstring& str);
+std::wstring as_wide(const std::string& str);
+----
+
+[NOTE]
+====
+Most examples in this documentation assume char interface and therefore will not compile with <<PUGIXML_WCHAR_MODE,PUGIXML_WCHAR_MODE>>. This is done to simplify the documentation; usually the only changes you'll have to make is to pass `wchar_t` string literals, i.e. instead of
+
+`xml_node node = doc.child("bookstore").find_child_by_attribute("book", "id", "12345");`
+
+you'll have to use
+
+`xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");`
+====
+
+[[dom.thread]]
+=== Thread-safety guarantees
+
+Almost all functions in pugixml have the following thread-safety guarantees:
+
+* it is safe to call free (non-member) functions from multiple threads
+* it is safe to perform concurrent read-only accesses to the same tree (all constant member functions do not modify the tree)
+* it is safe to perform concurrent read/write accesses, if there is only one read or write access to the single tree at a time
+
+Concurrent modification and traversing of a single tree requires synchronization, for example via reader-writer lock. Modification includes altering document structure and altering individual node/attribute data, i.e. changing names/values.
+
+The only exception is <<set_memory_management_functions,set_memory_management_functions>>; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see <<dom.memory.custom>>.
+
+[[dom.exception]]
+=== Exception guarantees
+
+With the exception of XPath, pugixml itself does not throw any exceptions. Additionally, most pugixml functions have a no-throw exception guarantee.
+
+This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. <<xml_node::traverse,xml_node::traverse>> or <<xml_node::find_node,xml_node::find_node>>) do not provide any exception guarantees beyond the ones provided by the callback.
+
+If exception handling is not disabled with <<PUGIXML_NO_EXCEPTIONS,PUGIXML_NO_EXCEPTIONS>> define, XPath functions may throw <<xpath_exception,xpath_exception>> on parsing errors; also, XPath functions may throw `std::bad_alloc` in low memory conditions. Still, XPath functions provide strong exception guarantee.
+
+[[dom.memory]]
+=== Memory management
+
+pugixml requests the memory needed for document storage in big chunks, and allocates document data inside those chunks. This section discusses replacing functions used for chunk allocation and internal memory management implementation.
+
+[[dom.memory.custom]]
+==== Custom memory allocation/deallocation functions
+
+[[allocation_function]][[deallocation_function]]
+All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free:
+
+[source]
+----
+typedef void* (*allocation_function)(size_t size);
+typedef void (*deallocation_function)(void* ptr);
+----
+
+[[set_memory_management_functions]][[get_memory_allocation_function]][[get_memory_deallocation_function]]
+You can use the following accessor functions to change or get current memory management functions:
+
+[source]
+----
+void set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
+allocation_function get_memory_allocation_function();
+deallocation_function get_memory_deallocation_function();
+----
+
+Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of `void*` and `double` types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to return null pointer (throwing an exception from allocation function results in undefined behavior).
+
+Deallocation function is called with the pointer that was returned by some call to allocation function; it is never called with a null pointer. If memory management functions are not thread-safe, library thread safety is not guaranteed.
+
+This is a simple example of custom memory management (link:samples/custom_memory_management.cpp[]):
+
+[source,indent=0]
+----
+include::samples/custom_memory_management.cpp[tags=decl]
+----
+[source,indent=0]
+----
+include::samples/custom_memory_management.cpp[tags=call]
+----
+
+When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.
+
+[[dom.memory.tuning]]
+==== Memory consumption tuning
+
+There are several important buffering optimizations in pugixml that rely on predefined constants. These constants have default values that were tuned for common usage patterns; for some applications, changing these constants might improve memory consumption or increase performance. Changing these constants is not recommended unless their default values result in visible problems.
+
+These constants can be tuned via configuration defines, as discussed in <<install.building.config>>; it is recommended to set them in `pugiconfig.hpp`.
+
+* `PUGIXML_MEMORY_PAGE_SIZE` controls the page size for document memory allocation. Memory for node/attribute objects is allocated in pages of the specified size. The default size is 32 Kb; for some applications the size is too large (i.e. embedded systems with little heap space or applications that keep lots of XML documents in memory). A minimum size of 1 Kb is recommended.
+
+* `PUGIXML_MEMORY_OUTPUT_STACK` controls the cumulative stack space required to output the node. Any output operation (i.e. saving a subtree to file) uses an internal buffering scheme for performance reasons. The default size is 10 Kb; if you're using node output from threads with little stack space, decreasing this value can prevent stack overflows. A minimum size of 1 Kb is recommended.
+
+* `PUGIXML_MEMORY_XPATH_PAGE_SIZE` controls the page size for XPath memory allocation. Memory for XPath query objects as well as internal memory for XPath evaluation is allocated in pages of the specified size. The default size is 4 Kb; if you have a lot of resident XPath query objects, you might need to decrease the size to improve memory consumption. A minimum size of 256 bytes is recommended.
+
+[[dom.memory.internals]]
+==== Document memory management internals
+
+Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the <<xml_document,xml_document>> object.
+
+When the document is loaded from file/buffer, unless an inplace loading function is used (see <<loading.memory>>), a complete copy of character stream is made; all names/values of nodes and attributes are allocated in this buffer. This buffer is allocated via a single large allocation and is only freed when document memory is reclaimed (i.e. if the <<xml_document,xml_document>> object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns.
+
+All additional memory, such as memory for document structure (node/attribute objects) and memory for node/attribute names/values is allocated in pages on the order of 32 Kb; actual objects are allocated inside the pages using a memory management scheme optimized for fast allocation/deallocation of many small objects. Because of the scheme specifics, the pages are only destroyed if all objects inside them are destroyed; also, generally destroying an object does not mean that subsequent object creation will reuse the same memory. This means that it is possible to devise a usage scheme which will lead to higher memory usage than expected; one example is adding a lot of nodes, and them removing all even numbered ones; not a single page is reclaimed in the process. However this is an example specifically crafted to produce unsatisfying behavior; in all practical usage scenarios the memory consumption is less than that of a general-purpose allocator because allocation meta-data is very small in size.
+
+[[loading]]
+== Loading document
+
+pugixml provides several functions for loading XML data from various places - files, C{plus}{plus} iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed for performance reasons. Also some XML transformations (i.e. EOL handling or attribute value normalization) can impact parsing speed and thus can be disabled. However for vast majority of XML documents there is no performance difference between different parsing options. Parsing options also control whether certain XML nodes are parsed; see <<loading.options>> for more information.
+
+XML data is always converted to internal character format (see <<dom.unicode>>) before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions automatically. Unless explicit encoding is specified, loading functions perform automatic encoding detection based on first few characters of XML data, so in almost all cases you do not have to specify document encoding. Encoding conversion is described in more detail in <<loading.encoding>>.
+
+[[loading.file]]
+=== Loading document from file
+
+[[xml_document::load_file]][[xml_document::load_file_wide]]
+The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:
+
+[source]
+----
+xml_parse_result xml_document::load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+xml_parse_result xml_document::load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+----
+
+These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <<loading.options>>) and input data encoding (see <<loading.encoding>>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.
+
+File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.
+
+`load_file` destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an <<xml_parse_result,xml_parse_result>> object; this object contains the operation status and the related information (i.e. last successfully parsed position in the input file, if parsing fails). See <<loading.errors>> for error handling details.
+
+This is an example of loading XML document from file (link:samples/load_file.cpp[]):
+
+[source,indent=0]
+----
+include::samples/load_file.cpp[tags=code]
+----
+
+[[loading.memory]]
+=== Loading document from memory
+
+[[xml_document::load_buffer]][[xml_document::load_buffer_inplace]][[xml_document::load_buffer_inplace_own]]
+Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from GZip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage:
+
+[source]
+----
+xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+----
+
+All functions accept the buffer which is represented by a pointer to XML data, `contents`, and data size in bytes. Also there are two optional arguments, which specify parsing options (see <<loading.options>>) and input data encoding (see <<loading.encoding>>). The buffer does not have to be zero-terminated.
+
+`load_buffer` function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - `load_buffer_inplace` and `load_buffer_inplace_own` store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer's lifetime exceeds that of the tree if you're using inplace functions. In addition to that, `load_buffer_inplace` does not assume ownership of the buffer, so you'll have to destroy it yourself; `load_buffer_inplace_own` assumes ownership of the buffer and destroys it once it is not needed. This means that if you're using `load_buffer_inplace_own`, you have to allocate memory with pugixml allocation function (you can get it via <<get_memory_allocation_function,get_memory_allocation_function>>).
+
+The best way from the performance/memory point of view is to load document using `load_buffer_inplace_own`; this function has maximum control of the buffer with XML data so it is able to avoid redundant copies and reduce peak memory usage while parsing. This is the recommended function if you have to load the document from memory and performance is critical.
+
+[[xml_document::load_string]]
+There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:
+
+[source]
+----
+xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options = parse_default);
+----
+
+It is equivalent to calling `load_buffer` with `size` being either `strlen(contents)` or `wcslen(contents) * sizeof(wchar_t)`, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.
+
+This is an example of loading XML document from memory using different functions (link:samples/load_memory.cpp[]):
+
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=decl]
+----
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=load_buffer]
+----
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=load_buffer_inplace_begin]
+
+include::samples/load_memory.cpp[tags=load_buffer_inplace_end]
+----
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=load_buffer_inplace_own]
+----
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=load_string]
+----
+
+[[loading.stream]]
+=== Loading document from C{plus}{plus} IOstreams
+
+[[xml_document::load_stream]]
+To enhance interoperability, pugixml provides functions for loading document from any object which implements C{plus}{plus} `std::istream` interface. This allows you to load documents from any standard C{plus}{plus} stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones:
+
+[source]
+----
+xml_parse_result xml_document::load(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+xml_parse_result xml_document::load(std::wistream& stream, unsigned int options = parse_default);
+----
+
+`load` with `std::istream` argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling `xml_document::load` on an opened `std::ifstream` object is equivalent to calling `xml_document::load_file`.
+
+`load` with `std::wstream` argument treats the stream contents as a wide character stream (encoding is always <<encoding_wchar,encoding_wchar>>). Because of this, using `load` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale.
+
+This is a simple example of loading XML document from file using streams (link:samples/load_stream.cpp[]); read the sample code for more complex examples involving wide streams and locales:
+
+[source,indent=0]
+----
+include::samples/load_stream.cpp[tags=code]
+----
+
+[[loading.errors]]
+=== Handling parsing errors
+
+[[xml_parse_result]]
+All document loading functions return the parsing result via `xml_parse_result` object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream:
+
+[source]
+----
+struct xml_parse_result
+{
+ xml_parse_status status;
+ ptrdiff_t offset;
+ xml_encoding encoding;
+
+ operator bool() const;
+ const char* description() const;
+};
+----
+
+[[xml_parse_status]][[xml_parse_result::status]]
+Parsing status is represented as the `xml_parse_status` enumeration and can be one of the following:
+
+* [[status_ok]]`status_ok` means that no error was encountered during parsing; the source stream represents the valid XML document which was fully parsed and converted to a tree.
+
+* [[status_file_not_found]]`status_file_not_found` is only returned by `load_file` function and means that file could not be opened.
+* [[status_io_error]]`status_io_error` is returned by `load_file` function and by `load` functions with `std::istream`/`std::wstream` arguments; it means that some I/O error has occurred during reading the file/stream.
+* [[status_out_of_memory]]`status_out_of_memory` means that there was not enough memory during some allocation; any allocation failure during parsing results in this error.
+* [[status_internal_error]]`status_internal_error` means that something went horribly wrong; currently this error does not occur
+
+* [[status_unrecognized_tag]]`status_unrecognized_tag` means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as `#`.
+* [[status_bad_pi]]`status_bad_pi` means that parsing stopped due to incorrect document declaration/processing instruction
+* [[status_bad_comment]]`status_bad_comment`, [[status_bad_cdata]]`status_bad_cdata`, [[status_bad_doctype]]`status_bad_doctype` and [[status_bad_pcdata]]`status_bad_pcdata` mean that parsing stopped due to the invalid construct of the respective type
+* [[status_bad_start_element]]`status_bad_start_element` means that parsing stopped because starting tag either had no closing `>` symbol or contained some incorrect symbol
+* [[status_bad_attribute]]`status_bad_attribute` means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that `<node attr=1>` is incorrect in XML)
+* [[status_bad_end_element]]`status_bad_end_element` means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and `>`)
+* [[status_end_element_mismatch]]`status_end_element_mismatch` means that parsing stopped because the closing tag did not match the opening one (i.e. `<node></nedo>`) or because some tag was not closed at all
+* [[status_no_document_element]]`status_no_document_element` means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document
+
+[[xml_parse_result::description]]
+`description()` member function can be used to convert parsing status to a string; the returned message is always in English, so you'll have to write your own function if you need a localized string. However please note that the exact messages returned by `description()` function may change from version to version, so any complex status handling should be based on `status` value. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call <<as_wide,as_wide>> to get the `wchar_t` string.
+
+If parsing failed because the source data was not a valid XML, the resulting tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that was successfully parsed. Obviously, the last element may have an unexpected name/value; for example, if the attribute value does not end with the necessary quotation mark, like in `<node attr="value>some data</node>` example, the value of attribute `attr` will contain the string `value>some data</node>`.
+
+[[xml_parse_result::offset]]
+In addition to the status code, parsing result has an `offset` member, which contains the offset of last successfully parsed character if parsing failed because of an error in source data; otherwise `offset` is 0. For parsing efficiency reasons, pugixml does not track the current line during parsing; this offset is in units of <<char_t,pugi::char_t>> (bytes for character mode, wide characters for wide character mode). Many text editors support 'Go To Position' feature - you can use it to locate the exact error position. Alternatively, if you're loading the document from memory, you can display the error chunk along with the error description (see the example code below).
+
+CAUTION: Offset is calculated in the XML buffer in native encoding; if encoding conversion is performed during parsing, offset can not be used to reliably track the error position.
+
+[[xml_parse_result::encoding]]
+Parsing result also has an `encoding` member, which can be used to check that the source data encoding was correctly guessed. It is equal to the exact encoding used during parsing (i.e. with the exact endianness); see <<loading.encoding>> for more information.
+
+[[xml_parse_result::bool]]
+Parsing result object can be implicitly converted to `bool`; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a `bool`: `if (doc.load_file("file.xml")) { ... } else { ... }`.
+
+This is an example of handling loading errors (link:samples/load_error_handling.cpp[]):
+
+[source,indent=0]
+----
+include::samples/load_error_handling.cpp[tags=code]
+----
+
+[[loading.options]]
+=== Parsing options
+
+All document loading functions accept the optional parameter `options`. This is a bitmask that customizes the parsing process: you can select the node types that are parsed and various transformations that are performed with the XML text. Disabling certain transformations can improve parsing performance for some documents; however, the code for all transformations is very well optimized, and thus the majority of documents won't get any performance benefit. As a rule of thumb, only modify parsing flags if you want to get some nodes in the document that are excluded by default (i.e. declaration or comment nodes).
+
+NOTE: You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use `mask | flag`; to disable a flag, use `mask & ~flag`.
+
+These flags control the resulting tree contents:
+
+* [[parse_declaration]]`parse_declaration` determines if XML document declaration (node with type <<node_declaration,node_declaration>>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is *off* by default.
+
+* [[parse_doctype]]`parse_doctype` determines if XML document type declaration (node with type <<node_doctype,node_doctype>>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is *off* by default.
+
+* [[parse_pi]]`parse_pi` determines if processing instructions (nodes with type <<node_pi,node_pi>>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. Note that `<?xml ...?>` (document declaration) is not considered to be a PI. This flag is *off* by default.
+
+* [[parse_comments]]`parse_comments` determines if comments (nodes with type <<node_comment,node_comment>>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is *off* by default.
+
+* [[parse_cdata]]`parse_cdata` determines if CDATA sections (nodes with type <<node_cdata,node_cdata>>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is *on* by default.
+
+* [[parse_trim_pcdata]]`parse_trim_pcdata` determines if leading and trailing whitespace characters are to be removed from PCDATA nodes. While for some applications leading/trailing whitespace is significant, often the application only cares about the non-whitespace contents so it's easier to trim whitespace from text during parsing. This flag is *off* by default.
+
+* [[parse_ws_pcdata]]`parse_ws_pcdata` determines if PCDATA nodes (nodes with type <<node_pcdata,node_pcdata>>) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string `<node> <a/> </node>`, `<node>` element will have three children when `parse_ws_pcdata` is set (child with type <<node_pcdata,node_pcdata>> and value `" "`, child with type <<node_element,node_element>> and name `"a"`, and another child with type <<node_pcdata,node_pcdata>> and value `" "`), and only one child when `parse_ws_pcdata` is not set. This flag is *off* by default.
+
+* [[parse_ws_pcdata_single]]`parse_ws_pcdata_single` determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. `<node> </node>`, but is not interested in whitespace markup elsewhere. It is possible to use <<parse_ws_pcdata,parse_ws_pcdata>> flag in this case, but it results in excessive allocations and complicates document processing; this flag can be used to avoid that. As an example, after parsing XML string `<node> <a> </a> </node>` with `parse_ws_pcdata_single` flag set, `<node>` element will have one child `<a>`, and `<a>` element will have one child with type <<node_pcdata,node_pcdata>> and value `" "`. This flag has no effect if <<parse_ws_pcdata,parse_ws_pcdata>> is enabled. This flag is *off* by default.
+
+* [[parse_fragment]]`parse_fragment` determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid. This flag is *off* by default.
+
+CAUTION: Using in-place parsing (<<xml_document::load_buffer_inplace,load_buffer_inplace>>) with `parse_fragment` flag may result in the loss of the last character of the buffer if it is a part of PCDATA. Since PCDATA values are null-terminated strings, the only way to resolve this is to provide a null-terminated buffer as an input to `load_buffer_inplace` - i.e. `doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment)`.
+
+These flags control the transformation of tree element contents:
+
+* [[parse_escapes]]`parse_escapes` determines if character and entity references are to be expanded during the parsing process. Character references have the form `&#...;` or `&#x...;` (`...` is Unicode numeric representation of character in either decimal (`&#...;`) or hexadecimal (`&#x...;`) form), entity references are `&amp;lt;`, `&amp;gt;`, `&amp;amp;`, `&amp;apos;` and `&amp;quot;` (note that as pugixml does not handle DTD, the only allowed entities are predefined ones). If character/entity reference can not be expanded, it is left as is, so you can do additional processing later. Reference expansion is performed on attribute values and PCDATA content. This flag is *on* by default.
+
+* [[parse_eol]]`parse_eol` determines if EOL handling (that is, replacing sequences `\r\n` by a single `\n` character, and replacing all standalone `\r` characters by `\n`) is to be performed on input data (that is, comment contents, PCDATA/CDATA contents and attribute values). This flag is *on* by default.
+
+* [[parse_wconv_attribute]]`parse_wconv_attribute` determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (`' '`). New line characters are always treated as if <<parse_eol,parse_eol>> is set, i.e. `\r\n` is converted to a single space. This flag is *on* by default.
+
+* [[parse_wnorm_attribute]]`parse_wnorm_attribute` determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if <<parse_wconv_attribute,parse_wconv_attribute>> was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. <<parse_wconv_attribute,parse_wconv_attribute>> has no effect if this flag is on. This flag is *off* by default.
+
+NOTE: `parse_wconv_attribute` option performs transformations that are required by W3C specification for attributes that are declared as CDATA; <<parse_wnorm_attribute,parse_wnorm_attribute>> performs transformations required for NMTOKENS attributes. In the absence of document type declaration all attributes should behave as if they are declared as CDATA, thus <<parse_wconv_attribute,parse_wconv_attribute>> is the default option.
+
+Additionally there are three predefined option masks:
+
+* [[parse_minimal]]`parse_minimal` has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice <<parse_default,parse_default>> is usually equally fast.
+
+* [[parse_default]]`parse_default` is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons.
+
+* [[parse_full]]`parse_full` is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode.
+
+This is an example of using different parsing options (link:samples/load_options.cpp[]):
+
+[source,indent=0]
+----
+include::samples/load_options.cpp[tags=code]
+----
+
+[[loading.encoding]]
+=== Encodings
+
+[[xml_encoding]]
+pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions. Most loading functions accept the optional parameter `encoding`. This is a value of enumeration type `xml_encoding`, that can have the following values:
+
+* [[encoding_auto]]`encoding_auto` means that pugixml will try to guess the encoding based on source XML data. The algorithm is a modified version of the one presented in http://www.w3.org/TR/REC-xml/#sec-guessing-no-ext-info[Appendix F.1 of XML recommendation]; it tries to match the first few bytes of input data with the following patterns in strict order:
+** If first four bytes match UTF-32 BOM (Byte Order Mark), encoding is assumed to be UTF-32 with the endianness equal to that of BOM;
+** If first two bytes match UTF-16 BOM, encoding is assumed to be UTF-16 with the endianness equal to that of BOM;
+** If first three bytes match UTF-8 BOM, encoding is assumed to be UTF-8;
+** If first four bytes match UTF-32 representation of `<`, encoding is assumed to be UTF-32 with the corresponding endianness;
+** If first four bytes match UTF-16 representation of `<?`, encoding is assumed to be UTF-16 with the corresponding endianness;
+** If first two bytes match UTF-16 representation of `<`, encoding is assumed to be UTF-16 with the corresponding endianness (this guess may yield incorrect result, but it's better than UTF-8);
+** Otherwise encoding is assumed to be UTF-8.
+
+* [[encoding_utf8]]`encoding_utf8` corresponds to UTF-8 encoding as defined in the Unicode standard; UTF-8 sequences with length equal to 5 or 6 are not standard and are rejected.
+* [[encoding_utf16_le]]`encoding_utf16_le` corresponds to little-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
+* [[encoding_utf16_be]]`encoding_utf16_be` corresponds to big-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
+* [[encoding_utf16]]`encoding_utf16` corresponds to UTF-16 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
+* [[encoding_utf32_le]]`encoding_utf32_le` corresponds to little-endian UTF-32 encoding as defined in the Unicode standard.
+* [[encoding_utf32_be]]`encoding_utf32_be` corresponds to big-endian UTF-32 encoding as defined in the Unicode standard.
+* [[encoding_utf32]]`encoding_utf32` corresponds to UTF-32 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
+* [[encoding_wchar]]`encoding_wchar` corresponds to the encoding of `wchar_t` type; it has the same meaning as either `encoding_utf16` or `encoding_utf32`, depending on `wchar_t` size.
+* [[encoding_latin1]]`encoding_latin1` corresponds to ISO-8859-1 encoding (also known as Latin-1).
+
+The algorithm used for `encoding_auto` correctly detects any supported Unicode encoding for all well-formed XML documents (since they start with document declaration) and for all other XML documents that start with `<`; if your XML document does not start with `<` and has encoding that is different from UTF-8, use the specific encoding.
+
+NOTE: The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; moreover, in case no encoding conversion is performed, the invalid sequences are not removed, so you'll get them as is in node/attribute contents.
+
+[[loading.w3c]]
+=== Conformance to W3C specification
+
+pugixml is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons.
+
+There is only one non-conformant behavior when dealing with valid XML documents: pugixml does not use information supplied in document type declaration for parsing. This means that entities declared in DOCTYPE are not expanded, and all attribute/PCDATA values are always processed in a uniform way that depends only on parsing options.
+
+As for rejecting invalid XML documents, there are a number of incompatibilities with W3C specification, including:
+
+* Multiple attributes of the same node can have equal names.
+* All non-ASCII characters are treated in the same way as symbols of English alphabet, so some invalid tag names are not rejected.
+* Attribute values which contain `<` are not rejected.
+* Invalid entity/character references are not rejected and are instead left as is.
+* Comment values can contain `--`.
+* XML data is not required to begin with document declaration; additionally, document declaration can appear after comments and other nodes.
+* Invalid document type declarations are silently ignored in some cases.
+
+[[access]]
+== Accessing document data
+
+pugixml features an extensive interface for getting various types of data from the document and for traversing the document. This section provides documentation for all such functions that do not modify the tree except for XPath-related functions; see <<xpath>> for XPath reference. As discussed in <<dom.cpp>>, there are two types of handles to tree data - <<xml_node,xml_node>> and <<xml_attribute,xml_attribute>>. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see <<node_null,this description>> for details. The documentation in this section will explicitly state the results of all function in case of null inputs.
+
+[import samples/traverse_base.cpp]
+
+[[access.basic]]
+=== Basic traversal functions
+
+[[xml_node::parent]][[xml_node::first_child]][[xml_node::last_child]][[xml_node::next_sibling]][[xml_node::previous_sibling]][[xml_node::first_attribute]][[xml_node::last_attribute]][[xml_attribute::next_attribute]][[xml_attribute::previous_attribute]]
+The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).
+
+[source]
+----
+xml_node xml_node::parent() const;
+xml_node xml_node::first_child() const;
+xml_node xml_node::last_child() const;
+xml_node xml_node::next_sibling() const;
+xml_node xml_node::previous_sibling() const;
+
+xml_attribute xml_node::first_attribute() const;
+xml_attribute xml_node::last_attribute() const;
+xml_attribute xml_attribute::next_attribute() const;
+xml_attribute xml_attribute::previous_attribute() const;
+----
+
+`parent` function returns the node's parent; all non-null nodes except the document have non-null parent. `first_child` and `last_child` return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. `next_sibling` and `previous_sibling` return the node that's immediately to the right/left of this node in the children list, respectively - for example, in `<a/><b/><c/>`, calling `next_sibling` for a handle that points to `<b/>` results in a handle pointing to `<c/>`, and calling `previous_sibling` results in handle pointing to `<a/>`. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. `first_attribute`, `last_attribute`, `next_attribute` and `previous_attribute` functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way.
+
+NOTE: Because of memory consumption reasons, attributes do not have a link to their parent nodes. Thus there is no `xml_attribute::parent()` function.
+
+Calling any of the functions above on the null handle results in a null handle - i.e. `node.first_child().next_sibling()` returns the second child of `node`, and null handle if `node` is null, has no children at all or if it has only one child node.
+
+With these functions, you can iterate through all child nodes and display all attributes like this (link:samples/traverse_base.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_base.cpp[tags=basic]
+----
+
+[[access.nodedata]]
+=== Getting node data
+
+[[xml_node::name]][[xml_node::value]]
+Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <<node_document,node_document>> nodes do not have a name or value, <<node_element,node_element>> and <<node_declaration,node_declaration>> nodes always have a name but never have a value, <<node_pcdata,node_pcdata>>, <<node_cdata,node_cdata>>, <<node_comment,node_comment>> and <<node_doctype,node_doctype>> nodes never have a name but always have a value (it may be empty though), <<node_pi,node_pi>> nodes always have a name and a value (again, value may be empty). In order to get node's name or value, you can use the following functions:
+
+[source]
+----
+const char_t* xml_node::name() const;
+const char_t* xml_node::value() const;
+----
+
+In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers.
+
+[[xml_node::child_value]]
+It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type <<node_pcdata,node_pcdata>> with value `"This is a node"`. pugixml provides several helper functions to parse such data:
+
+[source]
+----
+const char_t* xml_node::child_value() const;
+const char_t* xml_node::child_value(const char_t* name) const;
+xml_text xml_node::text() const;
+----
+
+`child_value()` returns the value of the first child with type <<node_pcdata,node_pcdata>> or <<node_cdata,node_cdata>>; `child_value(name)` is a simple wrapper for `child(name).child_value()`. For the above example, calling `node.child_value("description")` and `description.child_value()` will both produce string `"This is a node"`. If there is no child with relevant type, or if the handle is null, `child_value` functions return empty string.
+
+`text()` returns a special object that can be used for working with PCDATA contents in more complex cases than just retrieving the value; it is described in <<access.text>> sections.
+
+There is an example of using some of these functions <<code_traverse_base_data,at the end of the next section>>.
+
+[[access.attrdata]]
+=== Getting attribute data
+
+[[xml_attribute::name]][[xml_attribute::value]]
+All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for `xml_node`:
+
+[source]
+----
+const char_t* xml_attribute::name() const;
+const char_t* xml_attribute::value() const;
+----
+
+In case the attribute handle is null, both functions return empty strings - they never return null pointers.
+
+[[xml_attribute::as_string]]
+If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to `"sorted"` instead of `""`), you can use `as_string` accessor:
+
+[source]
+----
+const char_t* xml_attribute::as_string(const char_t* def = "") const;
+----
+
+It returns `def` argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to `value()`.
+
+[[xml_attribute::as_int]][[xml_attribute::as_uint]][[xml_attribute::as_double]][[xml_attribute::as_float]][[xml_attribute::as_bool]][[xml_attribute::as_llong]][[xml_attribute::as_ullong]]
+In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:
+
+[source]
+----
+int xml_attribute::as_int(int def = 0) const;
+unsigned int xml_attribute::as_uint(unsigned int def = 0) const;
+double xml_attribute::as_double(double def = 0) const;
+float xml_attribute::as_float(float def = 0) const;
+bool xml_attribute::as_bool(bool def = false) const;
+long long xml_attribute::as_llong(long long def = 0) const;
+unsigned long long xml_attribute::as_ullong(unsigned long long def = 0) const;
+----
+
+`as_int`, `as_uint`, `as_llong`, `as_ullong`, `as_double` and `as_float` convert attribute values to numbers. If attribute handle is null or attribute value is empty, `def` argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to `as_int`, `as_uint`, `as_llong` and `as_ullong`; hexadecimal format is used if the number has `0x` or `0X` prefix) or as a floating point number in either decimal or scientific form (`as_double` or `as_float`). Any extra characters are silently discarded, i.e. `as_int` will return `1` for string `"1abc"`.
+
+In case the input string contains a number that is out of the target numeric range, the result is undefined.
+
+CAUTION: Number conversion functions depend on current C locale as set with `setlocale`, so may return unexpected results if the locale is different from `"C"`.
+
+`as_bool` converts attribute value to boolean as follows: if attribute handle is null, `def` argument is returned (which is `false` by default). If attribute value is empty, `false` is returned. Otherwise, `true` is returned if the first character is one of `'1', 't', 'T', 'y', 'Y'`. This means that strings like `"true"` and `"yes"` are recognized as `true`, while strings like `"false"` and `"no"` are recognized as `false`. For more complex matching you'll have to write your own function.
+
+NOTE: `as_llong` and `as_ullong` are only available if your platform has reliable support for the `long long` type, including string conversions.
+
+[[code_traverse_base_data]]
+This is an example of using these functions, along with node data retrieval ones (link:samples/traverse_base.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_base.cpp[tags=data]
+----
+
+[[access.contents]]
+=== Contents-based traversal functions
+
+[[xml_node::child]][[xml_node::attribute]][[xml_node::next_sibling_name]][[xml_node::previous_sibling_name]]
+Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:
+
+[source]
+----
+xml_node xml_node::child(const char_t* name) const;
+xml_attribute xml_node::attribute(const char_t* name) const;
+xml_node xml_node::next_sibling(const char_t* name) const;
+xml_node xml_node::previous_sibling(const char_t* name) const;
+----
+
+`child` and `attribute` return the first child/attribute with the specified name; `next_sibling` and `previous_sibling` return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node/attribute with the specified name, null handle is returned.
+
+`child` and `next_sibling` functions can be used together to loop through all child nodes with the desired name like this:
+
+[source]
+----
+for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
+----
+
+[[xml_node::find_child_by_attribute]]
+Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: `<group><item id="1"/> <item id="2"/></group>`. There are two functions for finding child nodes based on the attribute values:
+
+[source]
+----
+xml_node xml_node::find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
+xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
+----
+
+The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive.
+
+In all of the above functions, all arguments have to be valid strings; passing null pointers results in undefined behavior.
+
+This is an example of using these functions (link:samples/traverse_base.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_base.cpp[tags=contents]
+----
+
+[[access.rangefor]]
+=== Range-based for-loop support
+
+[[xml_node::children]][[xml_node::attributes]]
+If your C{plus}{plus} compiler supports range-based for-loop (this is a C{plus}{plus}11 feature, at the time of writing it's supported by Microsoft Visual Studio 2012+, GCC 4.6+ and Clang 3.0+), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with http://www.boost.org/libs/foreach/[Boost Foreach], and possibly other pre-C{plus}{plus}11 foreach facilities.
+
+[source,subs="+quotes"]
+----
+_implementation_-_defined_-_type_ xml_node::children() const;
+_implementation_-_defined_-_type_ xml_node::children(const char_t* name) const;
+_implementation_-_defined_-_type_ xml_node::attributes() const;
+----
+
+`children` function allows you to enumerate all child nodes; `children` function with `name` argument allows you to enumerate all child nodes with a specific name; `attributes` function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using `children()`.
+
+This is an example of using these functions (link:samples/traverse_rangefor.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_rangefor.cpp[tags=code]
+----
+
+[[access.iterators]]
+=== Traversing node/attribute lists via iterators
+
+[[xml_node_iterator]][[xml_attribute_iterator]][[xml_node::begin]][[xml_node::end]][[xml_node::attributes_begin]][[xml_node::attributes_end]]
+Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes:
+
+[source]
+----
+class xml_node_iterator;
+class xml_attribute_iterator;
+
+typedef xml_node_iterator xml_node::iterator;
+iterator xml_node::begin() const;
+iterator xml_node::end() const;
+
+typedef xml_attribute_iterator xml_node::attribute_iterator;
+attribute_iterator xml_node::attributes_begin() const;
+attribute_iterator xml_node::attributes_end() const;
+----
+
+`begin` and `attributes_begin` return iterators that point to the first node/attribute, respectively; `end` and `attributes_end` return past-the-end iterator for node/attribute list, respectively - this iterator can't be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: `xml_node_iterator(node)`. For `xml_attribute_iterator`, you'll have to provide both an attribute and its parent node.
+
+`begin` and `end` return equal iterators if called on null node; such iterators can't be dereferenced. `attributes_begin` and `attributes_end` behave the same way. For correct iterator usage this means that child node/attribute collections of null nodes appear to be empty.
+
+Both types of iterators have bidirectional iterator semantics (i.e. they can be incremented and decremented, but efficient random access is not supported) and support all usual iterator operations - comparison, dereference, etc. The iterators are invalidated if the node/attribute objects they're pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.
+
+Here is an example of using iterators for document traversal (link:samples/traverse_iter.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_iter.cpp[tags=code]
+----
+
+CAUTION: Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference using assignment - i.e. passing iterators to a function like `std::sort` - will not give expected results, as assignment modifies local handle that's stored in the iterator.
+
+[[access.walker]]
+=== Recursive traversal with xml_tree_walker
+
+[[xml_tree_walker]]
+The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you'll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement `xml_tree_walker` interface and to call `traverse` function:
+
+[source]
+----
+class xml_tree_walker
+{
+public:
+ virtual bool begin(xml_node& node);
+ virtual bool for_each(xml_node& node) = 0;
+ virtual bool end(xml_node& node);
+
+ int depth() const;
+};
+
+bool xml_node::traverse(xml_tree_walker& walker);
+----
+
+[[xml_tree_walker::begin]][[xml_tree_walker::for_each]][[xml_tree_walker::end]][[xml_node::traverse]]
+The traversal is launched by calling `traverse` function on traversal root and proceeds as follows:
+
+* First, `begin` function is called with traversal root as its argument.
+* Then, `for_each` function is called for all nodes in the traversal subtree in depth first order, excluding the traversal root. Node is passed as an argument.
+* Finally, `end` function is called with traversal root as its argument.
+
+If `begin`, `end` or any of the `for_each` calls return `false`, the traversal is terminated and `false` is returned as the traversal result; otherwise, the traversal results in `true`. Note that you don't have to override `begin` or `end` functions; their default implementations return `true`.
+
+[[xml_tree_walker::depth]]
+You can get the node's depth relative to the traversal root at any point by calling `depth` function. It returns `-1` if called from `begin`/`end`, and returns 0-based depth if called from `for_each` - depth is 0 for all children of the traversal root, 1 for all grandchildren and so on.
+
+This is an example of traversing tree hierarchy with xml_tree_walker (link:samples/traverse_walker.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_walker.cpp[tags=impl]
+----
+[source,indent=0]
+----
+include::samples/traverse_walker.cpp[tags=traverse]
+----
+
+[[access.predicate]]
+=== Searching for nodes/attributes with predicates
+
+[[xml_node::find_attribute]][[xml_node::find_child]][[xml_node::find_node]]
+While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of `find_` functions:
+
+[source]
+----
+template <typename Predicate> xml_attribute xml_node::find_attribute(Predicate pred) const;
+template <typename Predicate> xml_node xml_node::find_child(Predicate pred) const;
+template <typename Predicate> xml_node xml_node::find_node(Predicate pred) const;
+----
+
+The predicate should be either a plain function or a function object which accepts one argument of type `xml_attribute` (for `find_attribute`) or `xml_node` (for `find_child` and `find_node`), and returns `bool`. The predicate is never called with null handle as an argument.
+
+`find_attribute` function iterates through all attributes of the specified node, and returns the first attribute for which the predicate returned `true`. If the predicate returned `false` for all attributes or if there were no attributes (including the case where the node is null), null attribute is returned.
+
+`find_child` function iterates through all child nodes of the specified node, and returns the first node for which the predicate returned `true`. If the predicate returned `false` for all nodes or if there were no child nodes (including the case where the node is null), null node is returned.
+
+`find_node` function performs a depth-first traversal through the subtree of the specified node (excluding the node itself), and returns the first node for which the predicate returned `true`. If the predicate returned `false` for all nodes or if subtree was empty, null node is returned.
+
+This is an example of using predicate-based functions (link:samples/traverse_predicate.cpp[]):
+
+[source,indent=0]
+----
+include::samples/traverse_predicate.cpp[tags=decl]
+----
+[source,indent=0]
+----
+include::samples/traverse_predicate.cpp[tags=find]
+----
+
+[[access.text]]
+=== Working with text contents
+
+[[xml_text]]
+It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type <<node_pcdata,node_pcdata>> with value `"This is a node"`. pugixml provides a special class, `xml_text`, to work with such data. Working with text objects to modify data is described in <<modify.text,the documentation for modifying document data>>; this section describes the access interface of `xml_text`.
+
+[[xml_node::text]]
+You can get the text object from a node by using `text()` method:
+
+[source]
+----
+xml_text xml_node::text() const;
+----
+
+If the node has a type `node_pcdata` or `node_cdata`, then the node itself is used to return data; otherwise, a first child node of type `node_pcdata` or `node_cdata` is used.
+
+[[xml_text::empty]][[xml_text::unspecified_bool_type]]
+You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. `if (text) { ... }` or `if (!text) { ... }`. Alternatively you can check it by using the `empty()` method:
+
+[source]
+----
+bool xml_text::empty() const;
+----
+
+[[xml_text::get]]
+Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:
+
+[source]
+----
+const char_t* xml_text::get() const;
+----
+
+In case text object is empty, the function returns an empty string - it never returns a null pointer.
+
+[[xml_text::as_string]][[xml_text::as_int]][[xml_text::as_uint]][[xml_text::as_double]][[xml_text::as_float]][[xml_text::as_bool]][[xml_text::as_llong]][[xml_text::as_ullong]]
+If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors:
+
+[source]
+----
+const char_t* xml_text::as_string(const char_t* def = "") const;
+int xml_text::as_int(int def = 0) const;
+unsigned int xml_text::as_uint(unsigned int def = 0) const;
+double xml_text::as_double(double def = 0) const;
+float xml_text::as_float(float def = 0) const;
+bool xml_text::as_bool(bool def = false) const;
+long long xml_text::as_llong(long long def = 0) const;
+unsigned long long xml_text::as_ullong(unsigned long long def = 0) const;
+----
+
+All of the above functions have the same semantics as similar `xml_attribute` members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can <<xml_attribute::as_int,refer to documentation for the attribute functions>> for details.
+
+[[xml_text::data]]
+`xml_text` is essentially a helper class that operates on `xml_node` values. It is bound to a node of type <<node_pcdata,node_pcdata>> or <<node_cdata,node_cdata>>. You can use the following function to retrieve this node:
+
+[source]
+----
+xml_node xml_text::data() const;
+----
+
+Essentially, assuming `text` is an `xml_text` object, calling `text.get()` is equivalent to calling `text.data().value()`.
+
+This is an example of using `xml_text` object (link:samples/text.cpp[]):
+
+[source,indent=0]
+----
+include::samples/text.cpp[tags=access]
+----
+
+[[access.misc]]
+=== Miscellaneous functions
+
+[[xml_node::root]]
+If you need to get the document root of some node, you can use the following function:
+
+[source]
+----
+xml_node xml_node::root() const;
+----
+
+This function returns the node with type <<node_document,node_document>>, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).
+
+[[xml_node::path]][[xml_node::first_element_by_path]]
+While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node:
+
+[source]
+----
+string_t xml_node::path(char_t delimiter = '/') const;
+xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const;
+----
+
+Node paths consist of node names, separated with a delimiter (which is `/` by default); also paths can contain self (`.`) and parent (`..`) pseudo-names, so that this is a valid path: `"../../foo/./bar"`. `path` returns the path to the node from the document root, `first_element_by_path` looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: `<a><b><c/></b></a>`, node `<c/>` has path `"a/b/c"`; calling `first_element_by_path` for document with path `"a/b"` results in node `<b/>`; calling `first_element_by_path` for node `<a/>` with path `"../a/./b/../."` results in node `<a/>`; calling `first_element_by_path` with path `"/a"` results in node `<a/>` for any node.
+
+In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of `first_element_by_path` is null node; also `first_element_by_path` returns null node for null nodes, in which case the path does not matter. `path` returns an empty string for null nodes.
+
+NOTE: `path` function returns the result as STL string, and thus is not available if <<PUGIXML_NO_STL,PUGIXML_NO_STL>> is defined.
+
+[[xml_node::offset_debug]]
+pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer:
+
+[source]
+----
+ptrdiff_t xml_node::offset_debug() const;
+----
+
+If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node's data from the beginning of XML buffer in <<char_t,pugi::char_t>> units. For more information on parsing offsets, see <<xml_parse_result::offset,parsing error handling documentation>>.
+
+[[modify]]
+== Modifying document data
+
+The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. This section provides documentation for the relevant functions. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.
+
+All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: `void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }`, so const-correctness here mainly provides additional documentation.
+
+[import samples/modify_base.cpp]
+
+[[modify.nodedata]]
+=== Setting node data
+
+[[xml_node::set_name]][[xml_node::set_value]]
+As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <<node_document,node_document>> nodes do not have a name or value, <<node_element,node_element>> and <<node_declaration,node_declaration>> nodes always have a name but never have a value, <<node_pcdata,node_pcdata>>, <<node_cdata,node_cdata>>, <<node_comment,node_comment>> and <<node_doctype,node_doctype>> nodes never have a name but always have a value (it may be empty though), <<node_pi,node_pi>> nodes always have a name and a value (again, value may be empty). In order to set node's name or value, you can use the following functions:
+
+[source]
+----
+bool xml_node::set_name(const char_t* rhs);
+bool xml_node::set_value(const char_t* rhs);
+----
+
+Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call `set_name` on a <<node_pcdata,node_pcdata>> node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.
+
+This is an example of setting node name and value (link:samples/modify_base.cpp[]):
+
+[source,indent=0]
+----
+include::samples/modify_base.cpp[tags=node]
+----
+
+[[modify.attrdata]]
+=== Setting attribute data
+
+[[xml_attribute::set_name]][[xml_attribute::set_value]]
+All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:
+
+[source]
+----
+bool xml_attribute::set_name(const char_t* rhs);
+bool xml_attribute::set_value(const char_t* rhs);
+----
+
+Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the attribute handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.
+
+In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values:
+
+[source]
+----
+bool xml_attribute::set_value(int rhs);
+bool xml_attribute::set_value(unsigned int rhs);
+bool xml_attribute::set_value(double rhs);
+bool xml_attribute::set_value(float rhs);
+bool xml_attribute::set_value(bool rhs);
+bool xml_attribute::set_value(long long rhs);
+bool xml_attribute::set_value(unsigned long long rhs);
+----
+
+The above functions convert the argument to string and then call the base `set_value` function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either `"true"` or `"false"`.
+
+CAUTION: Number conversion functions depend on current C locale as set with `setlocale`, so may generate unexpected results if the locale is different from `"C"`.
+
+NOTE: `set_value` overloads with `long long` type are only available if your platform has reliable support for the type, including string conversions.
+
+[[xml_attribute::assign]]
+
+For convenience, all `set_value` functions have the corresponding assignment operators:
+
+[source]
+----
+xml_attribute& xml_attribute::operator=(const char_t* rhs);
+xml_attribute& xml_attribute::operator=(int rhs);
+xml_attribute& xml_attribute::operator=(unsigned int rhs);
+xml_attribute& xml_attribute::operator=(double rhs);
+xml_attribute& xml_attribute::operator=(float rhs);
+xml_attribute& xml_attribute::operator=(bool rhs);
+xml_attribute& xml_attribute::operator=(long long rhs);
+xml_attribute& xml_attribute::operator=(unsigned long long rhs);
+----
+
+These operators simply call the right `set_value` function and return the attribute they're called on; the return value of `set_value` is ignored, so errors are ignored.
+
+This is an example of setting attribute name and value (link:samples/modify_base.cpp[]):
+
+[source,indent=0]
+----
+include::samples/modify_base.cpp[tags=attr]
+----
+
+[[modify.add]]
+=== Adding nodes/attributes
+
+[[xml_node::prepend_attribute]][[xml_node::append_attribute]][[xml_node::insert_attribute_after]][[xml_node::insert_attribute_before]][[xml_node::prepend_child]][[xml_node::append_child]][[xml_node::insert_child_after]][[xml_node::insert_child_before]]
+Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node:
+
+[source]
+----
+xml_attribute xml_node::append_attribute(const char_t* name);
+xml_attribute xml_node::prepend_attribute(const char_t* name);
+xml_attribute xml_node::insert_attribute_after(const char_t* name, const xml_attribute& attr);
+xml_attribute xml_node::insert_attribute_before(const char_t* name, const xml_attribute& attr);
+
+xml_node xml_node::append_child(xml_node_type type = node_element);
+xml_node xml_node::prepend_child(xml_node_type type = node_element);
+xml_node xml_node::insert_child_after(xml_node_type type, const xml_node& node);
+xml_node xml_node::insert_child_before(xml_node_type type, const xml_node& node);
+
+xml_node xml_node::append_child(const char_t* name);
+xml_node xml_node::prepend_child(const char_t* name);
+xml_node xml_node::insert_child_after(const char_t* name, const xml_node& node);
+xml_node xml_node::insert_child_before(const char_t* name, const xml_node& node);
+----
+
+`append_attribute` and `append_child` create a new node/attribute at the end of the corresponding list of the node the method is called on; `prepend_attribute` and `prepend_child` create a new node/attribute at the beginning of the list; `insert_attribute_after`, `insert_attribute_before`, `insert_child_after` and `insert_attribute_before` add the node/attribute before or after the specified node/attribute.
+
+Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the `type` argument create the node with the specified type; since node type can't be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the `name` argument create the element node (<<node_element,node_element>>) with the specified name.
+
+All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure:
+
+* Adding fails if the target node is null;
+* Only <<node_element,node_element>> nodes can contain attributes, so attribute adding fails if node is not an element;
+* Only <<node_document,node_document>> and <<node_element,node_element>> nodes can contain children, so child node adding fails if the target node is not an element or a document;
+* <<node_document,node_document>> and <<node_null,node_null>> nodes can not be inserted as children, so passing <<node_document,node_document>> or <<node_null,node_null>> value as `type` results in operation failure;
+* <<node_declaration,node_declaration>> nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails;
+* Adding node/attribute results in memory allocation, which may fail;
+* Insertion functions fail if the specified node or attribute is null or is not in the target node's children/attribute list.
+
+Even if the operation fails, the document remains in consistent state, but the requested node/attribute is not added.
+
+CAUTION: `attribute()` and `child()` functions do not add attributes or nodes to the tree, so code like `node.attribute("id") = 123;` will not do anything if `node` does not have an attribute with name `"id"`. Make sure you're operating with existing attributes/nodes by adding them if necessary.
+
+This is an example of adding new attributes/nodes to the document (link:samples/modify_add.cpp[]):
+
+[source,indent=0]
+----
+include::samples/modify_add.cpp[tags=code]
+----
+
+[[modify.remove]]
+=== Removing nodes/attributes
+
+[[xml_node::remove_attribute]][[xml_node::remove_child]]
+If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:
+
+[source]
+----
+bool xml_node::remove_attribute(const xml_attribute& a);
+bool xml_node::remove_child(const xml_node& n);
+----
+
+`remove_attribute` removes the attribute from the attribute list of the node, and returns the operation result. `remove_child` removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. Removing fails if one of the following is true:
+
+* The node the function is called on is null;
+* The attribute/node to be removed is null;
+* The attribute/node to be removed is not in the node's attribute/child list.
+
+Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed.
+
+If you want to remove the attribute or child node by its name, two additional helper functions are available:
+
+[source]
+----
+bool xml_node::remove_attribute(const char_t* name);
+bool xml_node::remove_child(const char_t* name);
+----
+
+These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns `false`; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: `while (node.remove_child("tool")) ;`.
+
+This is an example of removing attributes/nodes from the document (link:samples/modify_remove.cpp[]):
+
+[source,indent=0]
+----
+include::samples/modify_remove.cpp[tags=code]
+----
+
+[[modify.text]]
+=== Working with text contents
+
+pugixml provides a special class, `xml_text`, to work with text contents stored as a value of some node, i.e. `<node><description>This is a node</description></node>`. Working with text objects to retrieve data is described in <<access.text,the documentation for accessing document data>>; this section describes the modification interface of `xml_text`.
+
+[[xml_text::set]]
+Once you have an `xml_text` object, you can set the text contents using the following function:
+
+[source]
+----
+bool xml_text::set(const char_t* rhs);
+----
+
+This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a <<node_declaration,node_declaration>> node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from an element node, this function creates the PCDATA child node if necessary (i.e. if the element node does not have a PCDATA/CDATA child already).
+
+[[xml_text::set_value]]
+In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:
+
+[source]
+----
+bool xml_text::set(int rhs);
+bool xml_text::set(unsigned int rhs);
+bool xml_text::set(double rhs);
+bool xml_text::set(float rhs);
+bool xml_text::set(bool rhs);
+bool xml_text::set(long long rhs);
+bool xml_text::set(unsigned long long rhs);
+----
+
+The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can <<xml_attribute::set_value,refer to documentation for the attribute functions>> for details.
+
+[[xml_text::assign]]
+
+For convenience, all `set` functions have the corresponding assignment operators:
+
+[source]
+----
+xml_text& xml_text::operator=(const char_t* rhs);
+xml_text& xml_text::operator=(int rhs);
+xml_text& xml_text::operator=(unsigned int rhs);
+xml_text& xml_text::operator=(double rhs);
+xml_text& xml_text::operator=(float rhs);
+xml_text& xml_text::operator=(bool rhs);
+xml_text& xml_text::operator=(long long rhs);
+xml_text& xml_text::operator=(unsigned long long rhs);
+----
+
+These operators simply call the right `set` function and return the attribute they're called on; the return value of `set` is ignored, so errors are ignored.
+
+This is an example of using `xml_text` object to modify text contents (link:samples/text.cpp[]):
+
+[source,indent=0]
+----
+include::samples/text.cpp[tags=modify]
+----
+
+[[modify.clone]]
+=== Cloning nodes/attributes
+
+[[xml_node::prepend_copy]][[xml_node::append_copy]][[xml_node::insert_copy_after]][[xml_node::insert_copy_before]]
+With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can't create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions:
+
+[source]
+----
+xml_attribute xml_node::append_copy(const xml_attribute& proto);
+xml_attribute xml_node::prepend_copy(const xml_attribute& proto);
+xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
+xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
+
+xml_node xml_node::append_copy(const xml_node& proto);
+xml_node xml_node::prepend_copy(const xml_node& proto);
+xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node);
+xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node);
+----
+
+These functions mirror the structure of `append_child`, `prepend_child`, `insert_child_before` and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure.
+
+The attribute is copied along with the name and value; the node is copied along with its type, name and value; additionally attribute list and all children are recursively cloned, resulting in the deep subtree clone. The prototype object can be a part of the same document, or a part of any other document.
+
+The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, <<xml_node::append_child,consult their documentation for more information>>. There are additional caveats specific to cloning functions:
+
+* Cloning null handles results in operation failure;
+* Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since <<node_document,node_document>> is not a valid insertion type. The example below provides a workaround.
+* It is possible to copy a subtree as a child of some node inside this subtree, i.e. `node.append_copy(node.parent().parent());`. This is a valid operation, and it results in a clone of the subtree in the state before cloning started, i.e. no infinite recursion takes place.
+
+This is an example with one possible implementation of include tags in XML (link:samples/include.cpp[]). It illustrates node cloning and usage of other document modification functions:
+
+[source,indent=0]
+----
+include::samples/include.cpp[tags=code]
+----
+
+[[modify.move]]
+=== Moving nodes
+
+[[xml_node::prepend_move]][[xml_node::append_move]][[xml_node::insert_move_after]][[xml_node::insert_move_before]]
+Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:
+
+[source]
+----
+xml_node xml_node::append_move(const xml_node& moved);
+xml_node xml_node::prepend_move(const xml_node& moved);
+xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node);
+xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node);
+----
+
+These functions mirror the structure of `append_copy`, `prepend_copy`, `insert_copy_before` and `insert_copy_after` - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.
+
+The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, <<xml_node::append_child,consult their documentation for more information>>. There are additional caveats specific to moving functions:
+
+* Moving null handles results in operation failure;
+* Moving is only possible for nodes that belong to the same document; attempting to move nodes between documents will fail.
+* `insert_move_after` and `insert_move_before` functions fail if the moved node is the same as the `node` argument (this operation would be a no-op otherwise).
+* It is impossible to move a subtree to a child of some node inside this subtree, i.e. `node.append_move(node.parent().parent());` will fail.
+
+[[modify.fragments]]
+=== Assembling document from fragments
+
+[[xml_node::append_buffer]]
+pugixml provides several ways to assemble an XML document from other XML documents. Assuming there is a set of document fragments, represented as in-memory buffers, the implementation choices are as follows:
+
+* Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:
++
+[source]
+----
+bool append_fragment(pugi::xml_node target, const char* buffer, size_t size)
+{
+ pugi::xml_document doc;
+ if (!doc.load_buffer(buffer, size)) return false;
+
+ for (pugi::xml_node child = doc.first_child(); child; child = child.next_sibling())
+ target.append_copy(child);
+}
+----
+
+* Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment:
++
+[source]
+----
+bool append_fragment(pugi::xml_node target, const pugi::xml_document& cached_fragment)
+{
+ for (pugi::xml_node child = cached_fragment.first_child(); child; child = child.next_sibling())
+ target.append_copy(child);
+}
+----
+
+* Use `xml_node::append_buffer` directly:
++
+[source]
+----
+xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+----
+
+The first method is more convenient, but slower than the other two. The relative performance of `append_copy` and `append_buffer` depends on the buffer format - usually `append_buffer` is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending on `PUGIXML_WCHAR_MODE`). At the same time it might be less efficient in terms of memory usage - the implementation makes a copy of the provided buffer, and the copy has the same lifetime as the document - the memory used by that copy will be reclaimed after the document is destroyed, but no sooner. Even deleting all nodes in the document, including the appended ones, won't reclaim the memory.
+
+`append_buffer` behaves in the same way as <<xml_document::load_buffer,xml_document::load_buffer>> - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns.
+
+[[status_append_invalid_root]]
+Since `append_buffer` needs to append child nodes to the current node, it only works if the current node is either document or element node. Calling `append_buffer` on a node with any other type results in an error with `status_append_invalid_root` status.
+
+[[saving]]
+== Saving document
+
+Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format (see <<saving.options>>), and also perform necessary encoding conversions (see <<saving.encoding>>). This section documents the relevant functionality.
+
+Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as `<` and `&`, are properly escaped (unless <<format_no_escapes,format_no_escapes>> flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values.
+
+CDATA sections with values that contain `"]]>"` are split into several sections as follows: section with value `"pre]]>post"` is written as `<![CDATA[pre]]]]><![CDATA[>post]]>`. While this alters the structure of the document (if you load the document after saving it, there will be two CDATA sections instead of one), this is the only way to escape CDATA contents.
+
+[[saving.file]]
+=== Saving document to a file
+
+[[xml_document::save_file]][[xml_document::save_file_wide]]
+If you want to save the whole document to a file, you can use one of the following functions:
+
+[source]
+----
+bool xml_document::save_file(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+bool xml_document::save_file(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+----
+
+These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see <<saving.options>>) and output data encoding (see <<saving.encoding>>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.
+
+File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.
+
+[[xml_writer_file]]
+`save_file` opens the target file for writing, outputs the requested header (by default a document declaration is output, unless the document already has one), and then saves the document contents. If the file could not be opened, the function returns `false`. Calling `save_file` is equivalent to creating an `xml_writer_file` object with `FILE*` handle as the only constructor argument and then calling `save`; see <<saving.writer>> for writer interface details.
+
+This is a simple example of saving XML document to file (link:samples/save_file.cpp[]):
+
+[source,indent=0]
+----
+include::samples/save_file.cpp[tags=code]
+----
+
+[[saving.stream]]
+=== Saving document to C{plus}{plus} IOstreams
+
+[[xml_document::save_stream]]
+To enhance interoperability pugixml provides functions for saving document to any object which implements C{plus}{plus} `std::ostream` interface. This allows you to save documents to any standard C{plus}{plus} stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:
+
+[source]
+----
+void xml_document::save(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+void xml_document::save(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
+----
+
+`save` with `std::ostream` argument saves the document to the stream in the same way as `save_file` (i.e. with requested header and with encoding conversions). On the other hand, `save` with `std::wstream` argument saves the document to the wide stream with <<encoding_wchar,encoding_wchar>> encoding. Because of this, using `save` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale.
+
+[[xml_writer_stream]]
+Calling `save` with stream target is equivalent to creating an `xml_writer_stream` object with stream as the only constructor argument and then calling `save`; see <<saving.writer>> for writer interface details.
+
+This is a simple example of saving XML document to standard output (link:samples/save_stream.cpp[]):
+
+[source,indent=0]
+----
+include::samples/save_stream.cpp[tags=code]
+----
+
+[[saving.writer]]
+=== Saving document via writer interface
+
+[[xml_document::save]][[xml_writer]][[xml_writer::write]]
+All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input:
+
+[source]
+----
+class xml_writer
+{
+public:
+ virtual void write(const void* data, size_t size) = 0;
+};
+
+void xml_document::save(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+----
+
+In order to output the document via some custom transport, for example sockets, you should create an object which implements `xml_writer` interface and pass it to `save` function. `xml_writer::write` function is called with a buffer as an input, where `data` points to buffer start, and `size` is equal to the buffer size in bytes. `write` implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after `write` returns. The buffer contains the chunk of document data in the desired encoding.
+
+`write` function is called with relatively large blocks (size is usually several kilobytes, except for the last block that may be small), so there is often no need for additional buffering in the implementation.
+
+This is a simple example of custom writer for saving document data to STL string (link:samples/save_custom_writer.cpp[]); read the sample code for more complex examples:
+
+[source,indent=0]
+----
+include::samples/save_custom_writer.cpp[tags=code]
+----
+
+[[saving.subtree]]
+=== Saving a single subtree
+
+[[xml_node::print]][[xml_node::print_stream]]
+While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided:
+
+[source]
+----
+void xml_node::print(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
+void xml_node::print(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
+void xml_node::print(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
+----
+
+These functions have the same arguments with the same meaning as the corresponding `xml_document::save` functions, and allow you to save the subtree to either a C{plus}{plus} IOstream or to any object that implements `xml_writer` interface.
+
+Saving a subtree differs from saving the whole document: the process behaves as if <<format_write_bom,format_write_bom>> is off, and <<format_no_declaration,format_no_declaration>> is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node's children. Note that this also holds if you're saving a document; this example (link:samples/save_subtree.cpp[]) illustrates the difference:
+
+[source,indent=0]
+----
+include::samples/save_subtree.cpp[tags=code]
+----
+
+[[saving.options]]
+=== Output options
+
+All saving functions accept the optional parameter `flags`. This is a bitmask that customizes the output format; you can select the way the document nodes are printed and select the needed additional information that is output before the document contents.
+
+NOTE: You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use `mask | flag`; to disable a flag, use `mask & ~flag`.
+
+These flags control the resulting tree contents:
+
+* [[format_indent]]`format_indent` determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is `"\t"` by default). If this flag is on, before every node the indentation string is output several times, where the amount of indentation depends on the node's depth relative to the output subtree. This flag has no effect if <<format_raw,format_raw>> is enabled. This flag is *on* by default.
+
+* [[format_raw]]`format_raw` switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with <<parse_ws_pcdata,parse_ws_pcdata>> flag, to preserve the original document formatting as much as possible. This flag is *off* by default.
+
+* [[format_no_escapes]]`format_no_escapes` disables output escaping for attribute values and PCDATA contents. If this flag is off, special symbols (`"`, `&`, `<`, `>`) and all non-printable characters (those with codepoint values less than 32) are converted to XML escape sequences (i.e. `&amp;amp;`) during output. If this flag is on, no text processing is performed; therefore, output XML can be malformed if output contents contains invalid symbols (i.e. having a stray `<` in the PCDATA will make the output malformed). This flag is *off* by default.
+
+These flags control the additional output information:
+
+* [[format_no_declaration]]`format_no_declaration` disables default node declaration output. By default, if the document is saved via `save` or `save_file` function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in `xml_node::print` functions: they never output the default declaration. This flag is *off* by default.
+
+* [[format_write_bom]]`format_write_bom` enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document's encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in `xml_node::print` functions: they never output the BOM. This flag is *off* by default.
+
+* [[format_save_file_text]]`format_save_file_text` changes the file mode when using `save_file` function. By default, file is opened in binary mode, which means that the output file will
+contain platform-independent newline `\n` (ASCII 10). If this flag is on, file is opened in text mode, which on some systems changes the newline format (i.e. on Windows you can use this flag to output XML documents with `\r\n` (ASCII 13 10) newlines. This flag is *off* by default.
+
+Additionally, there is one predefined option mask:
+
+* [[format_default]]`format_default` is the default set of flags, i.e. it has all options set to their default values. It sets formatted output with indentation, without BOM and with default node declaration, if necessary.
+
+This is an example that shows the outputs of different output options (link:samples/save_options.cpp[]):
+
+[source,indent=0]
+----
+include::samples/save_options.cpp[tags=code]
+----
+
+[[saving.encoding]]
+=== Encodings
+
+pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions during output. The output encoding is set via the `encoding` parameter of saving functions, which is of type `xml_encoding`. The possible values for the encoding are documented in <<loading.encoding>>; the only flag that has a different meaning is `encoding_auto`.
+
+While all other flags set the exact encoding, `encoding_auto` is meant for automatic encoding detection. The automatic detection does not make sense for output encoding, since there is usually nothing to infer the actual encoding from, so here `encoding_auto` means UTF-8 encoding, which is the most popular encoding for XML data storage. This is also the default value of output encoding; specify another value if you do not want UTF-8 encoded output.
+
+Also note that wide stream saving functions do not have `encoding` argument and always assume <<encoding_wchar,encoding_wchar>> encoding.
+
+NOTE: The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; if your node/attribute names do not contain any valid UTF sequences, they may be output as if they are empty, which will result in malformed XML document.
+
+[[saving.declaration]]
+=== Customizing document declaration
+
+When you are saving the document using `xml_document::save()` or `xml_document::save_file()`, a default XML document declaration is output, if `format_no_declaration` is not specified and if the document does not have a declaration node. However, the default declaration is not customizable. If you want to customize the declaration output, you need to create the declaration node yourself.
+
+NOTE: By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag <<parse_declaration,parse_declaration>> to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving.
+
+Declaration node is a node with type <<node_declaration,node_declaration>>; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values.
+
+This is an example that shows how to create a custom declaration node (link:samples/save_declaration.cpp[]):
+
+[source,indent=0]
+----
+include::samples/save_declaration.cpp[tags=code]
+----
+
+[[xpath]]
+== XPath
+
+If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in <<xpath.w3c>>. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read http://www.w3schools.com/xpath/[W3Schools XPath tutorial], http://www.tizag.com/xmlTutorial/xpathtutorial.php[XPath tutorial at tizag.com], and http://www.w3.org/TR/xpath/[the XPath 1.0 specification].
+
+[[xpath.types]]
+=== XPath types
+
+[[xpath_value_type]][[xpath_type_number]][[xpath_type_string]][[xpath_type_boolean]][[xpath_type_node_set]][[xpath_type_none]]
+Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to `bool` type, number type corresponds to `double` type, string type corresponds to either `std::string` or `std::wstring`, depending on whether <<dom.unicode,wide character interface is enabled>>, and node set corresponds to <<xpath_node_set,xpath_node_set>> type. There is an enumeration, `xpath_value_type`, which can take the values `xpath_type_boolean`, `xpath_type_number`, `xpath_type_string` or `xpath_type_node_set`, accordingly.
+
+[[xpath_node]][[xpath_node::node]][[xpath_node::attribute]][[xpath_node::parent]]
+Because an XPath node can be either a node or an attribute, there is a special type, `xpath_node`, which is a discriminated union of these types. A value of this type contains two node handles, one of `xml_node` type, and another one of `xml_attribute` type; at most one of them can be non-null. The accessors to get these handles are available:
+
+[source]
+----
+xml_node xpath_node::node() const;
+xml_attribute xpath_node::attribute() const;
+----
+
+XPath nodes can be null, in which case both accessors return null handles.
+
+Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function:
+
+[source]
+----
+xml_node xpath_node::parent() const;
+----
+
+`parent` function returns the node's parent if the XPath node corresponds to `xml_node` handle (equivalent to `node().parent()`), or the node to which the attribute belongs to, if the XPath node corresponds to `xml_attribute` handle. For null nodes, `parent` returns null handle.
+
+[[xpath_node::unspecified_bool_type]][[xpath_node::comparison]]
+Like node and attribute handles, XPath node handles can be implicitly cast to boolean-like object to check if it is a null node, and also can be compared for equality with each other.
+
+[[xpath_node::ctor]]
+You can also create XPath nodes with one of the three constructors: the default constructor, the constructor that takes node argument, and the constructor that takes attribute and node arguments (in which case the attribute must belong to the attribute list of the node). The constructor from `xml_node` is implicit, so you can usually pass `xml_node` to functions that expect `xpath_node`. Apart from that you usually don't need to create your own XPath node objects, since they are returned to you via selection functions.
+
+[[xpath_node_set]]
+XPath expressions operate not on single nodes, but instead on node sets. A node set is a collection of nodes, which can be optionally ordered in either a forward document order or a reverse one. Document order is defined in XPath specification; an XPath node is before another node in document order if it appears before it in XML representation of the corresponding document.
+
+[[xpath_node_set::const_iterator]][[xpath_node_set::begin]][[xpath_node_set::end]]
+Node sets are represented by `xpath_node_set` object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors:
+
+[source]
+----
+typedef const xpath_node* xpath_node_set::const_iterator;
+const_iterator xpath_node_set::begin() const;
+const_iterator xpath_node_set::end() const;
+----
+
+[[xpath_node_set::index]][[xpath_node_set::size]][[xpath_node_set::empty]]
+And it also can be iterated via indices, just like `std::vector`:
+
+[source]
+----
+const xpath_node& xpath_node_set::operator[](size_t index) const;
+size_t xpath_node_set::size() const;
+bool xpath_node_set::empty() const;
+----
+
+All of the above operations have the same semantics as that of `std::vector`: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster.
+
+[[xpath_node_set::type]][[xpath_node_set::type_unsorted]][[xpath_node_set::type_sorted]][[xpath_node_set::type_sorted_reverse]][[xpath_node_set::sort]]
+The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:
+
+[source]
+----
+enum xpath_node_set::type_t {type_unsorted, type_sorted, type_sorted_reverse};
+type_t xpath_node_set::type() const;
+----
+
+`type` function returns the current order of nodes; `type_sorted` means that the nodes are in forward document order, `type_sorted_reverse` means that the nodes are in reverse document order, and `type_unsorted` means that neither order is guaranteed (nodes can accidentally be in a sorted order even if `type()` returns `type_unsorted`). If you require a specific order of iteration, you can change it via `sort` function:
+
+[source]
+----
+void xpath_node_set::sort(bool reverse = false);
+----
+
+Calling `sort` sorts the nodes in either forward or reverse document order, depending on the argument; after this call `type()` will return `type_sorted` or `type_sorted_reverse`.
+
+[[xpath_node_set::first]]
+Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:
+
+[source]
+----
+xpath_node xpath_node_set::first() const;
+----
+
+This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of `type()`), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.
+
+[[xpath_node_set::ctor]]
+While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (`const_iterator` is a typedef for `const xpath_node*`), and an optional type:
+
+[source]
+----
+xpath_node_set::xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
+----
+
+The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you'll have to ensure that the range contains no duplicates, and that the objects are sorted according to the `type` parameter. Otherwise XPath operations with this set may produce unexpected results.
+
+[[xpath.select]]
+=== Selecting nodes via XPath expression
+
+[[xml_node::select_node]][[xml_node::select_nodes]]
+If you want to select nodes that match some XPath expression, you can do it with the following functions:
+
+[source]
+----
+xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const;
+xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
+----
+
+`select_nodes` function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. `select_node` returns only the first node in document order from the result, and is equivalent to calling `select_nodes(query).first()`. If the XPath expression does not match anything, or the node handle is null, `select_nodes` returns an empty set, and `select_node` returns null XPath node.
+
+If exception handling is not disabled, both functions throw <<xpath_exception,xpath_exception>> if the query can not be compiled or if it returns a value with type other than node set; see <<xpath.errors>> for details.
+
+[[xml_node::select_node_precomp]][[xml_node::select_nodes_precomp]]
+While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you're doing many similar queries, consider compiling them into query objects (see <<xpath.query>> for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:
+
+[source]
+----
+xpath_node xml_node::select_node(const xpath_query& query) const;
+xpath_node_set xml_node::select_nodes(const xpath_query& query) const;
+----
+
+If exception handling is not disabled, both functions throw <<xpath_exception,xpath_exception>> if the query returns a value with type other than node set.
+
+This is an example of selecting nodes using XPath expressions (link:samples/xpath_select.cpp[]):
+
+[source,indent=0]
+----
+include::samples/xpath_select.cpp[tags=code]
+----
+
+[[xpath.query]]
+=== Using query objects
+
+[[xpath_query]]
+When you call `select_nodes` with an expression string as an argument, a query object is created behind the scenes. A query object represents a compiled XPath expression. Query objects can be needed in the following circumstances:
+
+* You can precompile expressions to query objects to save compilation time if it becomes an issue;
+* You can use query objects to evaluate XPath expressions which result in booleans, numbers or strings;
+* You can get the type of expression value via query object.
+
+Query objects correspond to `xpath_query` type. They are immutable and non-copyable: they are bound to the expression at creation time and can not be cloned. If you want to put query objects in a container, allocate them on heap via `new` operator and store pointers to `xpath_query` in the container.
+
+[[xpath_query::ctor]]
+You can create a query object with the constructor that takes XPath expression as an argument:
+
+[source]
+----
+explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
+----
+
+[[xpath_query::return_type]]
+The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, <<xpath_exception,xpath_exception>> is thrown if exception handling is not disabled (see <<xpath.errors>> for details). After the query is created, you can query the type of the evaluation result using the following function:
+
+[source]
+----
+xpath_value_type xpath_query::return_type() const;
+----
+
+[[xpath_query::evaluate_boolean]][[xpath_query::evaluate_number]][[xpath_query::evaluate_string]][[xpath_query::evaluate_node_set]][[xpath_query::evaluate_node]]
+You can evaluate the query using one of the following functions:
+
+[source]
+----
+bool xpath_query::evaluate_boolean(const xpath_node& n) const;
+double xpath_query::evaluate_number(const xpath_node& n) const;
+string_t xpath_query::evaluate_string(const xpath_node& n) const;
+xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const;
+xpath_node xpath_query::evaluate_node(const xpath_node& n) const;
+----
+
+All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, `evaluate_boolean`, `evaluate_number` and `evaluate_string` always return a result, but `evaluate_node_set` and `evaluate_node` result in an error if the return type is not node set (see <<xpath.errors>>).
+
+NOTE: Calling `node.select_nodes("query")` is equivalent to calling `xpath_query("query").evaluate_node_set(node)`. Calling `node.select_node("query")` is equivalent to calling `xpath_query("query").evaluate_node(node)`.
+
+[[xpath_query::evaluate_string_buffer]]
+Note that `evaluate_string` function returns the STL string; as such, it's not available in <<PUGIXML_NO_STL,PUGIXML_NO_STL>> mode and also usually allocates memory. There is another string evaluation function:
+
+[source]
+----
+size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
+----
+
+This function evaluates the string, and then writes the result to `buffer` (but at most `capacity` characters); then it returns the full size of the result in characters, including the terminating zero. If `capacity` is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:
+
+* First call the function with `buffer = 0` and `capacity = 0`; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters;
+* First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again.
+
+This is an example of using query objects (link:samples/xpath_query.cpp[]):
+
+[source,indent=0]
+----
+include::samples/xpath_query.cpp[tags=code]
+----
+
+[[xpath.variables]]
+=== Using variables
+
+XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries.
+
+Variable references have the form `$name`; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to `xpath_query` constructor or to `select_nodes`/`select_node` functions:
+
+[source]
+----
+explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
+xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const;
+xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
+----
+
+If you're using query objects, you can change the variable values before `evaluate`/`select` calls to change the query behavior.
+
+NOTE: The variable set pointer is stored in the query object; you have to ensure that the lifetime of the set exceeds that of query object.
+
+[[xpath_variable_set]]
+Variable sets correspond to `xpath_variable_set` type, which is essentially a variable container.
+
+[[xpath_variable_set::add]]
+You can add new variables with the following function:
+
+[source]
+----
+xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type);
+----
+
+The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure.
+
+New variables are assigned the default value which depends on the type: `0` for numbers, `false` for booleans, empty string for strings and empty set for node sets.
+
+[[xpath_variable_set::get]]
+You can get the existing variables with the following functions:
+
+[source]
+----
+xpath_variable* xpath_variable_set::get(const char_t* name);
+const xpath_variable* xpath_variable_set::get(const char_t* name) const;
+----
+
+The functions return the variable handle, or null pointer if the variable with the specified name is not found.
+
+[[xpath_variable_set::set]]
+Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return `false`; they also return `false` on allocation failure. Note that these functions do not perform any type conversions.
+
+[source]
+----
+bool xpath_variable_set::set(const char_t* name, bool value);
+bool xpath_variable_set::set(const char_t* name, double value);
+bool xpath_variable_set::set(const char_t* name, const char_t* value);
+bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value);
+----
+
+The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.
+
+[[xpath_variable]]
+If setting variables by name is not efficient enough, or if you have to inspect variable information or get variable values, you can use variable handles. A variable corresponds to the `xpath_variable` type, and a variable handle is simply a pointer to `xpath_variable`.
+
+[[xpath_variable::type]][[xpath_variable::name]]
+In order to get variable information, you can use one of the following functions:
+
+[source]
+----
+const char_t* xpath_variable::name() const;
+xpath_value_type xpath_variable::type() const;
+----
+
+Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.
+
+[[xpath_variable::get_boolean]][[xpath_variable::get_number]][[xpath_variable::get_string]][[xpath_variable::get_node_set]]
+In order to get variable value, you should use one of the following functions, depending on the variable type:
+
+[source]
+----
+bool xpath_variable::get_boolean() const;
+double xpath_variable::get_number() const;
+const char_t* xpath_variable::get_string() const;
+const xpath_node_set& xpath_variable::get_node_set() const;
+----
+
+These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (`false` for booleans, `NaN` for numbers, empty string for strings and empty set for node sets).
+
+[[xpath_variable::set]]
+In order to set variable value, you should use one of the following functions, depending on the variable type:
+
+[source]
+----
+bool xpath_variable::set(bool value);
+bool xpath_variable::set(double value);
+bool xpath_variable::set(const char_t* value);
+bool xpath_variable::set(const xpath_node_set& value);
+----
+
+These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return `false`; they also return `false` on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.
+
+This is an example of using variables in XPath queries (link:samples/xpath_variables.cpp[]):
+
+[source,indent=0]
+----
+include::samples/xpath_variables.cpp[tags=code]
+----
+
+[[xpath.errors]]
+=== Error handling
+
+There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with <<PUGIXML_NO_EXCEPTIONS,PUGIXML_NO_EXCEPTIONS>> define).
+
+[[xpath_exception]][[xpath_exception::result]][[xpath_exception::what]]
+By default, XPath functions throw `xpath_exception` object in case of errors; additionally, in the event any memory allocation fails, an `std::bad_alloc` exception is thrown. Also `xpath_exception` is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions:
+
+[source]
+----
+virtual const char* xpath_exception::what() const throw();
+const xpath_parse_result& xpath_exception::result() const;
+----
+
+[[xpath_query::unspecified_bool_type]][[xpath_query::result]]
+If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: `if (query) { ... }`. Additionally, you can get parsing result via the result() accessor:
+
+[source]
+----
+const xpath_parse_result& xpath_query::result() const;
+----
+
+Without exceptions, evaluating invalid query results in `false`, empty string, `NaN` or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.
+
+[[xpath_parse_result]]
+The information about parsing result is returned via `xpath_parse_result` object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:
+
+[source]
+----
+struct xpath_parse_result
+{
+ const char* error;
+ ptrdiff_t offset;
+
+ operator bool() const;
+ const char* description() const;
+};
+----
+
+[[xpath_parse_result::error]]
+Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string.
+
+[[xpath_parse_result::description]]
+`description()` member function can be used to get the error message; it never returns the null pointer, so you can safely use `description()` even if query parsing succeeded. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call <<as_wide,as_wide>> to get the `wchar_t` string.
+
+[[xpath_parse_result::offset]]
+In addition to the error message, parsing result has an `offset` member, which contains the offset of last successfully parsed character. This offset is in units of <<char_t,pugi::char_t>> (bytes for character mode, wide characters for wide character mode).
+
+[[xpath_parse_result::bool]]
+Parsing result object can be implicitly converted to `bool` like this: `if (result) { ... } else { ... }`.
+
+This is an example of XPath error handling (link:samples/xpath_error.cpp[]):
+
+[source,indent=0]
+----
+include::samples/xpath_error.cpp[tags=code]
+----
+
+[[xpath.w3c]]
+=== Conformance to W3C specification
+
+Because of the differences in document object models, performance considerations and implementation complexity, pugixml does not provide a fully conformant XPath 1.0 implementation. This is the current list of incompatibilities:
+
+* Consecutive text nodes sharing the same parent are not merged, i.e. in `<node>text1 <![CDATA[data]]> text2</node>` node should have one text node child, but instead has three.
+* Since the document type declaration is not used for parsing, `id()` function always returns an empty node set.
+* Namespace nodes are not supported (affects `namespace::` axis).
+* Name tests are performed on QNames in XML document instead of expanded names; for `<foo xmlns:ns1='uri' xmlns:ns2='uri'><ns1:child/><ns2:child/></foo>`, query `foo/ns1:*` will return only the first child, not both of them. Compliant XPath implementations can return both nodes if the user provides appropriate namespace declarations.
+* String functions consider a character to be either a single `char` value or a single `wchar_t` value, depending on the library configuration; this means that some string functions are not fully Unicode-aware. This affects `substring()`, `string-length()` and `translate()` functions.
+
+[[changes]]
+== Changelog
+
+:!numbered:
+
+[[v1.6]]
+=== v1.6 ^10.04.2015^
+
+Maintenance release. Changes:
+
+* Specification changes:
+ . Attribute/text values now use more digits when printing floating point numbers to guarantee round-tripping.
+ . Text nodes no longer get extra surrounding whitespace when pretty-printing nodes with mixed contents
+
+* Bug fixes:
+ . Fixed translate and normalize-space XPath functions to no longer return internal NUL characters
+ . Fixed buffer overrun on malformed comments inside DOCTYPE sections
+ . DOCTYPE parsing can no longer run out of stack space on malformed inputs (XML parsing is now using bounded stack space)
+ . Adjusted processing instruction output to avoid malformed documents if the PI value contains `?>`
+
+[[v1.5]]
+=== v1.5 ^27.11.2014^
+
+Major release, featuring a lot of performance improvements and some new features.
+
+* Specification changes:
+ . `xml_document::load(const char_t*)` was renamed to `load_string`; the old method is still available and will be deprecated in a future release
+ . `xml_node::select_single_node` was renamed to `select_node`; the old method is still available and will be deprecated in a future release.
+
+* New features:
+ . Added `xml_node::append_move` and other functions for moving nodes within a document
+ . Added `xpath_query::evaluate_node` for evaluating queries with a single node as a result
+
+* Performance improvements:
+ . Optimized XML parsing (10-40% faster with clang/gcc, up to 10% faster with MSVC)
+ . Optimized memory consumption when copying nodes in the same document (string contents is now shared)
+ . Optimized node copying (10% faster for cross-document copies, 3x faster for inter-document copies; also it now consumes a constant amount of stack space)
+ . Optimized node output (60% faster; also it now consumes a constant amount of stack space)
+ . Optimized XPath allocation (query evaluation now results in fewer temporary allocations)
+ . Optimized XPath sorting (node set sorting is 2-3x faster in some cases)
+ . Optimized XPath evaluation (XPathMark suite is 100x faster; some commonly used queries are 3-4x faster)
+
+* Compatibility improvements:
+ . Fixed `xml_node::offset_debug` for corner cases
+ . Fixed undefined behavior while calling memcpy in some cases
+ . Fixed MSVC 2015 compilation warnings
+ . Fixed `contrib/foreach.hpp` for Boost 1.56.0
+
+* Bug fixes
+ . Adjusted comment output to avoid malformed documents if the comment value contains `--`
+ . Fix XPath sorting for documents that were constructed using append_buffer
+ . Fix `load_file` for wide-character paths with non-ASCII characters in MinGW with C{plus}{plus}11 mode enabled
+
+[[v1.4]]
+=== v1.4 ^27.02.2014^
+
+Major release, featuring various new features, bug fixes and compatibility improvements.
+
+* Specification changes:
+ . Documents without element nodes are now rejected with `status_no_document_element` error, unless `parse_fragment` option is used
+
+* New features:
+ . Added XML fragment parsing (`parse_fragment` flag)
+ . Added PCDATA whitespace trimming (`parse_trim_pcdata` flag)
+ . Added long long support for `xml_attribute` and `xml_text` (`as_llong`, `as_ullong` and `set_value`/`set` overloads)
+ . Added hexadecimal integer parsing support for `as_int`/`as_uint`/`as_llong`/`as_ullong`
+ . Added `xml_node::append_buffer` to improve performance of assembling documents from fragments
+ . `xml_named_node_iterator` is now bidirectional
+ . Reduced XPath stack consumption during compilation and evaluation (useful for embedded systems)
+
+* Compatibility improvements:
+ . Improved support for platforms without wchar_t support
+ . Fixed several false positives in clang static analysis
+ . Fixed several compilation warnings for various GCC versions
+
+* Bug fixes:
+ . Fixed undefined pointer arithmetic in XPath implementation
+ . Fixed non-seekable iostream support for certain stream types, i.e. Boost `file_source` with pipe input
+ . Fixed `xpath_query::return_type` for some expressions
+ . Fixed dllexport issues with `xml_named_node_iterator`
+ . Fixed `find_child_by_attribute` assertion for attributes with null name/value
+
+[[v1.2]]
+=== v1.2 ^1.05.2012^
+
+Major release, featuring header-only mode, various interface enhancements (i.e. PCDATA manipulation and C{plus}{plus}11 iteration), many other features and compatibility improvements.
+
+* New features:
+ . Added `xml_text` helper class for working with PCDATA/CDATA contents of an element node
+ . Added optional header-only mode (controlled by `PUGIXML_HEADER_ONLY` define)
+ . Added `xml_node::children()` and `xml_node::attributes()` for C{plus}{plus}11 ranged for loop or `BOOST_FOREACH`
+ . Added support for Latin-1 (ISO-8859-1) encoding conversion during loading and saving
+ . Added custom default values for `xml_attribute::as_*` (they are returned if the attribute does not exist)
+ . Added `parse_ws_pcdata_single` flag for preserving whitespace-only PCDATA in case it's the only child
+ . Added `format_save_file_text` for `xml_document::save_file` to open files as text instead of binary (changes newlines on Windows)
+ . Added `format_no_escapes` flag to disable special symbol escaping (complements `~parse_escapes`)
+ . Added support for loading document from streams that do not support seeking
+ . Added `PUGIXML_MEMORY_*` constants for tweaking allocation behavior (useful for embedded systems)
+ . Added `PUGIXML_VERSION` preprocessor define
+
+* Compatibility improvements:
+ . Parser does not require setjmp support (improves compatibility with some embedded platforms, enables `/clr:pure` compilation)
+ . STL forward declarations are no longer used (fixes SunCC/RWSTL compilation, fixes clang compilation in C{plus}{plus}11 mode)
+ . Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C{plus}{plus}/CLI compilation
+ . Fixed several compilation warnings for various GCC versions, Intel C{plus}{plus} compiler and Clang
+
+* Bug fixes:
+ . Fixed unsafe bool conversion to avoid problems on C{plus}{plus}/CLI
+ . Iterator dereference operator is const now (fixes Boost `filter_iterator` support)
+ . `xml_document::save_file` now checks for file I/O errors during saving
+
+[[v1.0]]
+=== v1.0 ^1.11.2010^
+
+Major release, featuring many XPath enhancements, wide character filename support, miscellaneous performance improvements, bug fixes and more.
+
+* XPath:
+ . XPath implementation is moved to `pugixml.cpp` (which is the only source file now); use `PUGIXML_NO_XPATH` if you want to disable XPath to reduce code size
+ . XPath is now supported without exceptions (`PUGIXML_NO_EXCEPTIONS`); the error handling mechanism depends on the presence of exception support
+ . XPath is now supported without STL (`PUGIXML_NO_STL`)
+ . Introduced variable support
+ . Introduced new `xpath_query::evaluate_string`, which works without STL
+ . Introduced new `xpath_node_set` constructor (from an iterator range)
+ . Evaluation function now accept attribute context nodes
+ . All internal allocations use custom allocation functions
+ . Improved error reporting; now a last parsed offset is returned together with the parsing error
+
+* Bug fixes:
+ . Fixed memory leak for loading from streams with stream exceptions turned on
+ . Fixed custom deallocation function calling with null pointer in one case
+ . Fixed missing attributes for iterator category functions; all functions/classes can now be DLL-exported
+ . Worked around Digital Mars compiler bug, which lead to minor read overfetches in several functions
+ . `load_file` now works with 2+ Gb files in MSVC/MinGW
+ . XPath: fixed memory leaks for incorrect queries
+ . XPath: fixed `xpath_node()` attribute constructor with empty attribute argument
+ . XPath: fixed `lang()` function for non-ASCII arguments
+
+* Specification changes:
+ . CDATA nodes containing `]]>` are printed as several nodes; while this changes the internal structure, this is the only way to escape CDATA contents
+ . Memory allocation errors during parsing now preserve last parsed offset (to give an idea about parsing progress)
+ . If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children)
+
+* Additional functionality:
+ . Added `xml_parse_result` default constructor
+ . Added `xml_document::load_file` and `xml_document::save_file` with wide character paths
+ . Added `as_utf8` and `as_wide` overloads for `std::wstring`/`std::string` arguments
+ . Added DOCTYPE node type (`node_doctype`) and a special parse flag, `parse_doctype`, to add such nodes to the document during parsing
+ . Added `parse_full` parse flag mask, which extends `parse_default` with all node type parsing flags except `parse_ws_pcdata`
+ . Added `xml_node::hash_value()` and `xml_attribute::hash_value()` functions for use in hash-based containers
+ . Added `internal_object()` and additional constructor for both `xml_node` and `xml_attribute` for easier marshalling (useful for language bindings)
+ . Added `xml_document::document_element()` function
+ . Added `xml_node::prepend_attribute`, `xml_node::prepend_child` and `xml_node::prepend_copy` functions
+ . Added `xml_node::append_child`, `xml_node::prepend_child`, `xml_node::insert_child_before` and `xml_node::insert_child_after` overloads for element nodes (with name instead of type)
+ . Added `xml_document::reset()` function
+
+* Performance improvements:
+ . `xml_node::root()` and `xml_node::offset_debug()` are now O(1) instead of O(logN)
+ . Minor parsing optimizations
+ . Minor memory optimization for strings in DOM tree (`set_name`/`set_value`)
+ . Memory optimization for string memory reclaiming in DOM tree (`set_name`/`set_value` now reallocate the buffer if memory waste is too big)
+ . XPath: optimized document order sorting
+ . XPath: optimized child/attribute axis step
+ . XPath: optimized number-to-string conversions in MSVC
+ . XPath: optimized concat for many arguments
+ . XPath: optimized evaluation allocation mechanism: constant and document strings are not heap-allocated
+ . XPath: optimized evaluation allocation mechanism: all temporaries' allocations use fast stack-like allocator
+
+* Compatibility:
+ . Removed wildcard functions (`xml_node::child_w`, `xml_node::attribute_w`, etc.)
+ . Removed `xml_node::all_elements_by_name`
+ . Removed `xpath_type_t` enumeration; use `xpath_value_type` instead
+ . Removed `format_write_bom_utf8` enumeration; use `format_write_bom` instead
+ . Removed `xml_document::precompute_document_order`, `xml_attribute::document_order` and `xml_node::document_order` functions; document order sort optimization is now automatic
+ . Removed `xml_document::parse` functions and `transfer_ownership` struct; use `xml_document::load_buffer_inplace` and `xml_document::load_buffer_inplace_own` instead
+ . Removed `as_utf16` function; use `as_wide` instead
+
+[[v0.9]]
+=== v0.9 ^1.07.2010^
+
+Major release, featuring extended and improved Unicode support, miscellaneous performance improvements, bug fixes and more.
+
+* Major Unicode improvements:
+ . Introduced encoding support (automatic/manual encoding detection on load, manual encoding selection on save, conversion from/to UTF8, UTF16 LE/BE, UTF32 LE/BE)
+ . Introduced `wchar_t` mode (you can set `PUGIXML_WCHAR_MODE` define to switch pugixml internal encoding from UTF8 to `wchar_t`; all functions are switched to their Unicode variants)
+ . Load/save functions now support wide streams
+
+* Bug fixes:
+ . Fixed document corruption on failed parsing bug
+ . XPath string/number conversion improvements (increased precision, fixed crash for huge numbers)
+ . Improved DOCTYPE parsing: now parser recognizes all well-formed DOCTYPE declarations
+ . Fixed `xml_attribute::as_uint()` for large numbers (i.e. 2^32^-1)
+ . Fixed `xml_node::first_element_by_path` for path components that are prefixes of node names, but are not exactly equal to them.
+
+* Specification changes:
+ . `parse()` API changed to `load_buffer`/`load_buffer_inplace`/`load_buffer_inplace_own`; `load_buffer` APIs do not require zero-terminated strings.
+ . Renamed `as_utf16` to `as_wide`
+ . Changed `xml_node::offset_debug` return type and `xml_parse_result::offset` type to `ptrdiff_t`
+ . Nodes/attributes with empty names are now printed as `:anonymous`
+
+* Performance improvements:
+ . Optimized document parsing and saving
+ . Changed internal memory management: internal allocator is used for both metadata and name/value data; allocated pages are deleted if all allocations from them are deleted
+ . Optimized memory consumption: `sizeof(xml_node_struct)` reduced from 40 bytes to 32 bytes on x86
+ . Optimized debug mode parsing/saving by order of magnitude
+
+* Miscellaneous:
+ . All STL includes except `<exception>` in `pugixml.hpp` are replaced with forward declarations
+ . `xml_node::remove_child` and `xml_node::remove_attribute` now return the operation result
+
+* Compatibility:
+ . `parse()` and `as_utf16` are left for compatibility (these functions are deprecated and will be removed in version 1.0)
+ . Wildcard functions, `document_order`/`precompute_document_order` functions, `all_elements_by_name` function and `format_write_bom_utf8` flag are deprecated and will be removed in version 1.0
+ . `xpath_type_t` enumeration was renamed to `xpath_value_type`; `xpath_type_t` is deprecated and will be removed in version 1.0
+
+[[v0.5]]
+=== v0.5 ^8.11.2009^
+
+Major bugfix release. Changes:
+
+* XPath bugfixes:
+ . Fixed `translate()`, `lang()` and `concat()` functions (infinite loops/crashes)
+ . Fixed compilation of queries with empty literal strings (`""`)
+ . Fixed axis tests: they never add empty nodes/attributes to the resulting node set now
+ . Fixed string-value evaluation for node-set (the result excluded some text descendants)
+ . Fixed `self::` axis (it behaved like `ancestor-or-self::`)
+ . Fixed `following::` and `preceding::` axes (they included descendent and ancestor nodes, respectively)
+ . Minor fix for `namespace-uri()` function (namespace declaration scope includes the parent element of namespace declaration attribute)
+ . Some incorrect queries are no longer parsed now (i.e. `foo: *`)
+ . Fixed `text()`/etc. node test parsing bug (i.e. `foo[text()]` failed to compile)
+ . Fixed root step (`/`) - it now selects empty node set if query is evaluated on empty node
+ . Fixed string to number conversion (`"123 "` converted to NaN, `"123 .456"` converted to 123.456 - now the results are 123 and NaN, respectively)
+ . Node set copying now preserves sorted type; leads to better performance on some queries
+
+* Miscellaneous bugfixes:
+ . Fixed `xml_node::offset_debug` for PI nodes
+ . Added empty attribute checks to `xml_node::remove_attribute`
+ . Fixed `node_pi` and `node_declaration` copying
+ . Const-correctness fixes
+
+* Specification changes:
+ . `xpath_node::select_nodes()` and related functions now throw exception if expression return type is not node set (instead of assertion)
+ . `xml_node::traverse()` now sets depth to -1 for both `begin()` and `end()` callbacks (was 0 at `begin()` and -1 at `end()`)
+ . In case of non-raw node printing a newline is output after PCDATA inside nodes if the PCDATA has siblings
+ . UTF8 -> `wchar_t` conversion now considers 5-byte UTF8-like sequences as invalid
+
+* New features:
+ . Added `xpath_node_set::operator[]` for index-based iteration
+ . Added `xpath_query::return_type()`
+ . Added getter accessors for memory-management functions
+
+[[v0.42]]
+=== v0.42 ^17.09.2009^
+
+Maintenance release. Changes:
+
+* Bug fixes:
+ . Fixed deallocation in case of custom allocation functions or if `delete[]` / `free` are incompatible
+ . XPath parser fixed for incorrect queries (i.e. incorrect XPath queries should now always fail to compile)
+ . Const-correctness fixes for `find_child_by_attribute`
+ . Improved compatibility (miscellaneous warning fixes, fixed `<cstring>` include dependency for GCC)
+ . Fixed iterator begin/end and print function to work correctly for empty nodes
+
+* New features:
+ . Added `PUGIXML_API`/`PUGIXML_CLASS`/`PUGIXML_FUNCTION` configuration macros to control class/function attributes
+ . Added `xml_attribute::set_value` overloads for different types
+
+[[v0.41]]
+=== v0.41 ^8.02.2009^
+
+Maintenance release. Changes:
+
+* Bug fixes:
+ . Fixed bug with node printing (occasionally some content was not written to output stream)
+
+[[v0.4]]
+=== v0.4 ^18.01.2009^
+
+Changes:
+
+* Bug fixes:
+ . Documentation fix in samples for `parse()` with manual lifetime control
+ . Fixed document order sorting in XPath (it caused wrong order of nodes after `xpath_node_set::sort` and wrong results of some XPath queries)
+
+* Node printing changes:
+ . Single quotes are no longer escaped when printing nodes
+ . Symbols in second half of ASCII table are no longer escaped when printing nodes; because of this, `format_utf8` flag is deleted as it's no longer needed and `format_write_bom` is renamed to `format_write_bom_utf8`.
+ . Reworked node printing - now it works via `xml_writer` interface; implementations for `FILE*` and `std::ostream` are available. As a side-effect, `xml_document::save_file` now works without STL.
+
+* New features:
+ . Added unsigned integer support for attributes (`xml_attribute::as_uint`, `xml_attribute::operator=`)
+ . Now document declaration (`<?xml ...?>`) is parsed as node with type `node_declaration` when `parse_declaration` flag is specified (access to encoding/version is performed as if they were attributes, i.e. `doc.child("xml").attribute("version").as_float()`); corresponding flags for node printing were also added
+ . Added support for custom memory management (see `set_memory_management_functions` for details)
+ . Implemented node/attribute copying (see `xml_node::insert_copy_*` and `xml_node::append_copy` for details)
+ . Added `find_child_by_attribute` and `find_child_by_attribute_w` to simplify parsing code in some cases (i.e. COLLADA files)
+ . Added file offset information querying for debugging purposes (now you're able to determine exact location of any `xml_node` in parsed file, see `xml_node::offset_debug` for details)
+ . Improved error handling for parsing - now `load()`, `load_file()` and `parse()` return `xml_parse_result`, which contains error code and last parsed offset; this does not break old interface as `xml_parse_result` can be implicitly casted to `bool`.
+
+[[v0.34]]
+=== v0.34 ^31.10.2007^
+
+Maintenance release. Changes:
+
+* Bug fixes:
+ . Fixed bug with loading from text-mode iostreams
+ . Fixed leak when `transfer_ownership` is true and parsing is failing
+ . Fixed bug in saving (`\r` and `\n` are now escaped in attribute values)
+ . Renamed `free()` to `destroy()` - some macro conflicts were reported
+
+* New features:
+ . Improved compatibility (supported Digital Mars C{plus}{plus}, MSVC 6, CodeWarrior 8, PGI C{plus}{plus}, Comeau, supported PS3 and XBox360)
+ . `PUGIXML_NO_EXCEPTION` flag for platforms without exception handling
+
+[[v0.3]]
+=== v0.3 ^21.02.2007^
+
+Refactored, reworked and improved version. Changes:
+
+* Interface:
+ . Added XPath
+ . Added tree modification functions
+ . Added no STL compilation mode
+ . Added saving document to file
+ . Refactored parsing flags
+ . Removed `xml_parser` class in favor of `xml_document`
+ . Added transfer ownership parsing mode
+ . Modified the way `xml_tree_walker` works
+ . Iterators are now non-constant
+
+* Implementation:
+ . Support of several compilers and platforms
+ . Refactored and sped up parsing core
+ . Improved standard compliancy
+ . Added XPath implementation
+ . Fixed several bugs
+
+[[v0.2]]
+=== v0.2 ^6.11.2006^
+
+First public release. Changes:
+
+* Bug fixes:
+ . Fixed `child_value()` (for empty nodes)
+ . Fixed `xml_parser_impl` warning at W4
+
+* New features:
+ . Introduced `child_value(name)` and `child_value_w(name)`
+ . `parse_eol_pcdata` and `parse_eol_attribute` flags + `parse_minimal` optimizations
+ . Optimizations of `strconv_t`
+
+[[v0.1]]
+=== v0.1 ^15.07.2006^
+
+First private release for testing purposes
+
+:numbered:
+
+[[apiref]]
+== API Reference
+
+This is the reference for all macros, types, enumerations, classes and functions in pugixml. Each symbol is a link that leads to the relevant section of the manual.
+
+[[apiref.macros]]
+=== Macros
+
+[source,subs="+macros"]
+----
+#define +++<a href="#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a>+++
+#define +++<a href="#PUGIXML_NO_XPATH">PUGIXML_NO_XPATH</a>+++
+#define +++<a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a>+++
+#define +++<a href="#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a>+++
+#define +++<a href="#PUGIXML_API">PUGIXML_API</a>+++
+#define +++<a href="#PUGIXML_CLASS">PUGIXML_CLASS</a>+++
+#define +++<a href="#PUGIXML_FUNCTION">PUGIXML_FUNCTION</a>+++
+#define +++<a href="#PUGIXML_MEMORY_PAGE_SIZE">PUGIXML_MEMORY_PAGE_SIZE</a>+++
+#define +++<a href="#PUGIXML_MEMORY_OUTPUT_STACK">PUGIXML_MEMORY_OUTPUT_STACK</a>+++
+#define +++<a href="#PUGIXML_MEMORY_XPATH_PAGE_SIZE">PUGIXML_MEMORY_XPATH_PAGE_SIZE</a>+++
+#define +++<a href="#PUGIXML_HEADER_ONLY">PUGIXML_HEADER_ONLY</a>+++
+#define +++<a href="#PUGIXML_HAS_LONG_LONG">PUGIXML_HAS_LONG_LONG</a>+++
+----
+
+[[apiref.types]]
+=== Types
+
+[source,subs="+macros"]
+----
+typedef configuration-defined-type +++<a href="#char_t">char_t</a>+++;
+typedef configuration-defined-type +++<a href="#string_t">string_t</a>+++;
+typedef void* (*+++<a href="#allocation_function">allocation_function</a>+++)(size_t size);
+typedef void (*+++<a href="#deallocation_function">deallocation_function</a>+++)(void* ptr);
+----
+
+[[apiref.enums]]
+=== Enumerations
+
+[source,subs="+macros"]
+----
+enum +++<a href="#xml_node_type">xml_node_type</a>+++
+ +++<a href="#node_null">node_null</a>+++
+ +++<a href="#node_document">node_document</a>+++
+ +++<a href="#node_element">node_element</a>+++
+ +++<a href="#node_pcdata">node_pcdata</a>+++
+ +++<a href="#node_cdata">node_cdata</a>+++
+ +++<a href="#node_comment">node_comment</a>+++
+ +++<a href="#node_pi">node_pi</a>+++
+ +++<a href="#node_declaration">node_declaration</a>+++
+ +++<a href="#node_doctype">node_doctype</a>+++
+
+enum +++<a href="#xml_parse_status">xml_parse_status</a>+++
+ +++<a href="#status_ok">status_ok</a>+++
+ +++<a href="#status_file_not_found">status_file_not_found</a>+++
+ +++<a href="#status_io_error">status_io_error</a>+++
+ +++<a href="#status_out_of_memory">status_out_of_memory</a>+++
+ +++<a href="#status_internal_error">status_internal_error</a>+++
+ +++<a href="#status_unrecognized_tag">status_unrecognized_tag</a>+++
+ +++<a href="#status_bad_pi">status_bad_pi</a>+++
+ +++<a href="#status_bad_comment">status_bad_comment</a>+++
+ +++<a href="#status_bad_cdata">status_bad_cdata</a>+++
+ +++<a href="#status_bad_doctype">status_bad_doctype</a>+++
+ +++<a href="#status_bad_pcdata">status_bad_pcdata</a>+++
+ +++<a href="#status_bad_start_element">status_bad_start_element</a>+++
+ +++<a href="#status_bad_attribute">status_bad_attribute</a>+++
+ +++<a href="#status_bad_end_element">status_bad_end_element</a>+++
+ +++<a href="#status_end_element_mismatch">status_end_element_mismatch</a>+++
+ +++<a href="#status_append_invalid_root">status_append_invalid_root</a>+++
+ +++<a href="#status_no_document_element">status_no_document_element</a>+++
+
+enum +++<a href="#xml_encoding">xml_encoding</a>+++
+ +++<a href="#encoding_auto">encoding_auto</a>+++
+ +++<a href="#encoding_utf8">encoding_utf8</a>+++
+ +++<a href="#encoding_utf16_le">encoding_utf16_le</a>+++
+ +++<a href="#encoding_utf16_be">encoding_utf16_be</a>+++
+ +++<a href="#encoding_utf16">encoding_utf16</a>+++
+ +++<a href="#encoding_utf32_le">encoding_utf32_le</a>+++
+ +++<a href="#encoding_utf32_be">encoding_utf32_be</a>+++
+ +++<a href="#encoding_utf32">encoding_utf32</a>+++
+ +++<a href="#encoding_wchar">encoding_wchar</a>+++
+ +++<a href="#encoding_latin1">encoding_latin1</a>+++
+
+enum +++<a href="#xpath_value_type">xpath_value_type</a>+++
+ +++<a href="#xpath_type_none">xpath_type_none</a>+++
+ +++<a href="#xpath_type_node_set">xpath_type_node_set</a>+++
+ +++<a href="#xpath_type_number">xpath_type_number</a>+++
+ +++<a href="#xpath_type_string">xpath_type_string</a>+++
+ +++<a href="#xpath_type_boolean">xpath_type_boolean</a>+++
+----
+
+[[apiref.constants]]
+=== Constants
+
+[source,subs="+macros"]
+----
+// Formatting options bit flags:
+const unsigned int +++<a href="#format_default">format_default</a>+++
+const unsigned int +++<a href="#format_indent">format_indent</a>+++
+const unsigned int +++<a href="#format_no_declaration">format_no_declaration</a>+++
+const unsigned int +++<a href="#format_no_escapes">format_no_escapes</a>+++
+const unsigned int +++<a href="#format_raw">format_raw</a>+++
+const unsigned int +++<a href="#format_save_file_text">format_save_file_text</a>+++
+const unsigned int +++<a href="#format_write_bom">format_write_bom</a>+++
+
+// Parsing options bit flags:
+const unsigned int +++<a href="#parse_cdata">parse_cdata</a>+++
+const unsigned int +++<a href="#parse_comments">parse_comments</a>+++
+const unsigned int +++<a href="#parse_declaration">parse_declaration</a>+++
+const unsigned int +++<a href="#parse_default">parse_default</a>+++
+const unsigned int +++<a href="#parse_doctype">parse_doctype</a>+++
+const unsigned int +++<a href="#parse_eol">parse_eol</a>+++
+const unsigned int +++<a href="#parse_escapes">parse_escapes</a>+++
+const unsigned int +++<a href="#parse_fragment">parse_fragment</a>+++
+const unsigned int +++<a href="#parse_full">parse_full</a>+++
+const unsigned int +++<a href="#parse_minimal">parse_minimal</a>+++
+const unsigned int +++<a href="#parse_pi">parse_pi</a>+++
+const unsigned int +++<a href="#parse_trim_pcdata">parse_trim_pcdata</a>+++
+const unsigned int +++<a href="#parse_ws_pcdata">parse_ws_pcdata</a>+++
+const unsigned int +++<a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a>+++
+const unsigned int +++<a href="#parse_wconv_attribute">parse_wconv_attribute</a>+++
+const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>+++
+----
+
+[[apiref.classes]]
+=== Classes
+
+[source,subs="+macros"]
+----
++++<span class="tok-k">class</span> <a href="#xml_attribute">xml_attribute</a>+++
+ +++<a href="#xml_attribute::ctor">xml_attribute</a>+++();
+
+ bool +++<a href="#xml_attribute::empty">empty</a>+++() const;
+ operator +++<a href="#xml_attribute::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+
+ bool +++<a href="#xml_attribute::comparison">operator==</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator!=</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator&lt;</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator&gt;</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator&lt;=</a>+++(const xml_attribute& r) const;
+ bool +++<a href="#xml_attribute::comparison">operator&gt;=</a>+++(const xml_attribute& r) const;
+
+ size_t +++<a href="#xml_attribute::hash_value">hash_value</a>+++() const;
+
+ xml_attribute +++<a href="#xml_attribute::next_attribute">next_attribute</a>+++() const;
+ xml_attribute +++<a href="#xml_attribute::previous_attribute">previous_attribute</a>+++() const;
+
+ const char_t* +++<a href="#xml_attribute::name">name</a>+++() const;
+ const char_t* +++<a href="#xml_attribute::value">value</a>+++() const;
+
+ const char_t* +++<a href="#xml_attribute::as_string">as_string</a>+++(const char_t* def = "") const;
+ int +++<a href="#xml_attribute::as_int">as_int</a>+++(int def = 0) const;
+ unsigned int +++<a href="#xml_attribute::as_uint">as_uint</a>+++(unsigned int def = 0) const;
+ double +++<a href="#xml_attribute::as_double">as_double</a>+++(double def = 0) const;
+ float +++<a href="#xml_attribute::as_float">as_float</a>+++(float def = 0) const;
+ bool +++<a href="#xml_attribute::as_bool">as_bool</a>+++(bool def = false) const;
+ long long +++<a href="#xml_attribute::as_llong">as_llong</a>+++(long long def = 0) const;
+ unsigned long long +++<a href="#xml_attribute::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
+
+ bool +++<a href="#xml_attribute::set_name">set_name</a>+++(const char_t* rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(const char_t* rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(int rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(unsigned int rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(double rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(float rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(bool rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(long long rhs);
+ bool +++<a href="#xml_attribute::set_value">set_value</a>+++(unsigned long long rhs);
+
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(const char_t* rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(int rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(unsigned int rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(double rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(float rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(bool rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(long long rhs);
+ xml_attribute& +++<a href="#xml_attribute::assign">operator=</a>+++(unsnigned long long rhs);
+
++++<span class="tok-k">class</span> <a href="#xml_node">xml_node</a>+++
+ +++<a href="#xml_node::ctor">xml_node</a>+++();
+
+ bool +++<a href="#xml_node::empty">empty</a>+++() const;
+ operator +++<a href="#xml_node::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+
+ bool +++<a href="#xml_node::comparison">operator==</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator!=</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator&lt;</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator&gt;</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator&lt;=</a>+++(const xml_node& r) const;
+ bool +++<a href="#xml_node::comparison">operator&gt;=</a>+++(const xml_node& r) const;
+
+ size_t +++<a href="#xml_node::hash_value">hash_value</a>+++() const;
+
+ xml_node_type +++<a href="#xml_node::type">type</a>+++() const;
+
+ const char_t* +++<a href="#xml_node::name">name</a>+++() const;
+ const char_t* +++<a href="#xml_node::value">value</a>+++() const;
+
+ xml_node +++<a href="#xml_node::parent">parent</a>+++() const;
+ xml_node +++<a href="#xml_node::first_child">first_child</a>+++() const;
+ xml_node +++<a href="#xml_node::last_child">last_child</a>+++() const;
+ xml_node +++<a href="#xml_node::next_sibling">next_sibling</a>+++() const;
+ xml_node +++<a href="#xml_node::previous_sibling">previous_sibling</a>+++() const;
+
+ xml_attribute +++<a href="#xml_node::first_attribute">first_attribute</a>+++() const;
+ xml_attribute +++<a href="#xml_node::last_attribute">last_attribute</a>+++() const;
+
+ implementation-defined-type +++<a href="#xml_node::children">children</a>+++() const;
+ implementation-defined-type +++<a href="#xml_node::children">children</a>+++(const char_t* name) const;
+ implementation-defined-type +++<a href="#xml_node::attributes">attributes</a>+++() const;
+
+ xml_node +++<a href="#xml_node::child">child</a>+++(const char_t* name) const;
+ xml_attribute +++<a href="#xml_node::attribute">attribute</a>+++(const char_t* name) const;
+ xml_node +++<a href="#xml_node::next_sibling_name">next_sibling</a>+++(const char_t* name) const;
+ xml_node +++<a href="#xml_node::previous_sibling_name">previous_sibling</a>+++(const char_t* name) const;
+ xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
+ xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* attr_name, const char_t* attr_value) const;
+
+ const char_t* +++<a href="#xml_node::child_value">child_value</a>+++() const;
+ const char_t* +++<a href="#xml_node::child_value">child_value</a>+++(const char_t* name) const;
+ xml_text +++<a href="#xml_node::text">text</a>+++() const;
+
+ typedef xml_node_iterator +++<a href="#xml_node_iterator">iterator</a>+++;
+ iterator +++<a href="#xml_node::begin">begin</a>+++() const;
+ iterator +++<a href="#xml_node::end">end</a>+++() const;
+
+ typedef xml_attribute_iterator +++<a href="#xml_attribute_iterator">attribute_iterator</a>+++;
+ attribute_iterator +++<a href="#xml_node::attributes_begin">attributes_begin</a>+++() const;
+ attribute_iterator +++<a href="#xml_node::attributes_end">attributes_end</a>+++() const;
+
+ bool +++<a href="#xml_node::traverse">traverse</a>+++(xml_tree_walker& walker);
+
+ template <typename Predicate> xml_attribute +++<a href="#xml_node::find_attribute">find_attribute</a>+++(Predicate pred) const;
+ template <typename Predicate> xml_node +++<a href="#xml_node::find_child">find_child</a>+++(Predicate pred) const;
+ template <typename Predicate> xml_node +++<a href="#xml_node::find_node">find_node</a>+++(Predicate pred) const;
+
+ string_t +++<a href="#xml_node::path">path</a>+++(char_t delimiter = '/') const;
+ xml_node +++<a href="#xml_node::first_element_by_path">xml_node::first_element_by_path</a>+++(const char_t* path, char_t delimiter = '/') const;
+ xml_node +++<a href="#xml_node::root">root</a>+++() const;
+ ptrdiff_t +++<a href="#xml_node::offset_debug">offset_debug</a>+++() const;
+
+ bool +++<a href="#xml_node::set_name">set_name</a>+++(const char_t* rhs);
+ bool +++<a href="#xml_node::set_value">set_value</a>+++(const char_t* rhs);
+
+ xml_attribute +++<a href="#xml_node::append_attribute">append_attribute</a>+++(const char_t* name);
+ xml_attribute +++<a href="#xml_node::prepend_attribute">prepend_attribute</a>+++(const char_t* name);
+ xml_attribute +++<a href="#xml_node::insert_attribute_after">insert_attribute_after</a>+++(const char_t* name, const xml_attribute& attr);
+ xml_attribute +++<a href="#xml_node::insert_attribute_before">insert_attribute_before</a>+++(const char_t* name, const xml_attribute& attr);
+
+ xml_node +++<a href="#xml_node::append_child">append_child</a>+++(xml_node_type type = node_element);
+ xml_node +++<a href="#xml_node::prepend_child">prepend_child</a>+++(xml_node_type type = node_element);
+ xml_node +++<a href="#xml_node::insert_child_after">insert_child_after</a>+++(xml_node_type type, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_child_before">insert_child_before</a>+++(xml_node_type type, const xml_node& node);
+
+ xml_node +++<a href="#xml_node::append_child">append_child</a>+++(const char_t* name);
+ xml_node +++<a href="#xml_node::prepend_child">prepend_child</a>+++(const char_t* name);
+ xml_node +++<a href="#xml_node::insert_child_after">insert_child_after</a>+++(const char_t* name, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_child_before">insert_child_before</a>+++(const char_t* name, const xml_node& node);
+
+ xml_attribute +++<a href="#xml_node::append_copy">append_copy</a>+++(const xml_attribute& proto);
+ xml_attribute +++<a href="#xml_node::prepend_copy">prepend_copy</a>+++(const xml_attribute& proto);
+ xml_attribute +++<a href="#xml_node::insert_copy_after">insert_copy_after</a>+++(const xml_attribute& proto, const xml_attribute& attr);
+ xml_attribute +++<a href="#xml_node::insert_copy_before">insert_copy_before</a>+++(const xml_attribute& proto, const xml_attribute& attr);
+
+ xml_node +++<a href="#xml_node::append_copy">append_copy</a>+++(const xml_node& proto);
+ xml_node +++<a href="#xml_node::prepend_copy">prepend_copy</a>+++(const xml_node& proto);
+ xml_node +++<a href="#xml_node::insert_copy_after">insert_copy_after</a>+++(const xml_node& proto, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_copy_before">insert_copy_before</a>+++(const xml_node& proto, const xml_node& node);
+
+ xml_node +++<a href="#xml_node::append_move">append_move</a>+++(const xml_node& moved);
+ xml_node +++<a href="#xml_node::prepend_move">prepend_move</a>+++(const xml_node& moved);
+ xml_node +++<a href="#xml_node::insert_move_after">insert_move_after</a>+++(const xml_node& moved, const xml_node& node);
+ xml_node +++<a href="#xml_node::insert_move_before">insert_move_before</a>+++(const xml_node& moved, const xml_node& node);
+
+ bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const xml_attribute& a);
+ bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const char_t* name);
+ bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const xml_node& n);
+ bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const char_t* name);
+
+ xml_parse_result +++<a href="#xml_node::append_buffer">append_buffer</a>+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+
+ void +++<a href="#xml_node::print">print</a>+++(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
+ void +++<a href="#xml_node::print_stream">print</a>+++(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
+ void +++<a href="#xml_node::print_stream">print</a>+++(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
+
+ xpath_node +++<a href="#xml_node::select_node">select_node</a>+++(const char_t* query, xpath_variable_set* variables = 0) const;
+ xpath_node +++<a href="#xml_node::select_node_precomp">select_node</a>+++(const xpath_query& query) const;
+ xpath_node_set +++<a href="#xml_node::select_nodes">select_nodes</a>+++(const char_t* query, xpath_variable_set* variables = 0) const;
+ xpath_node_set +++<a href="#xml_node::select_nodes_precomp">select_nodes</a>+++(const xpath_query& query) const;
+
++++<span class="tok-k">class</span> <a href="#xml_document">xml_document</a>+++
+ +++<a href="#xml_document::ctor">xml_document</a>+++();
+ ~+++<a href="#xml_document::dtor">xml_document</a>+++();
+
+ void +++<a href="#xml_document::reset">reset</a>+++();
+ void +++<a href="#xml_document::reset">reset</a>+++(const xml_document& proto);
+
+ xml_parse_result +++<a href="#xml_document::load_stream">load</a>+++(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_stream">load</a>+++(std::wistream& stream, unsigned int options = parse_default);
+
+ xml_parse_result +++<a href="#xml_document::load_string">load_string</a>+++(const char_t* contents, unsigned int options = parse_default);
+
+ xml_parse_result +++<a href="#xml_document::load_file">load_file</a>+++(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_file_wide">load_file</a>+++(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+
+ xml_parse_result +++<a href="#xml_document::load_buffer">load_buffer</a>+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_buffer_inplace">load_buffer_inplace</a>+++(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+ xml_parse_result +++<a href="#xml_document::load_buffer_inplace_own">load_buffer_inplace_own</a>+++(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
+
+ bool +++<a href="#xml_document::save_file">save_file</a>+++(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+ bool +++<a href="#xml_document::save_file_wide">save_file</a>+++(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+
+ void +++<a href="#xml_document::save_stream">save</a>+++(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+ void +++<a href="#xml_document::save_stream">save</a>+++(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
+
+ void +++<a href="#xml_document::save">save</a>+++(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
+
+ xml_node +++<a href="#xml_document::document_element">document_element</a>+++() const;
+
++++<span class="tok-k">struct</span> <a href="#xml_parse_result">xml_parse_result</a>+++
+ xml_parse_status +++<a href="#xml_parse_result::status">status</a>+++;
+ ptrdiff_t +++<a href="#xml_parse_result::offset">offset</a>+++;
+ xml_encoding +++<a href="#xml_parse_result::encoding">encoding</a>+++;
+
+ operator +++<a href="#xml_parse_result::bool">bool</a>+++() const;
+ const char* +++<a href="#xml_parse_result::description">description</a>+++() const;
+
++++<span class="tok-k">class</span> <a href="#xml_node_iterator">xml_node_iterator</a>+++
++++<span class="tok-k">class</span> <a href="#xml_attribute_iterator">xml_attribute_iterator</a>+++
+
++++<span class="tok-k">class</span> <a href="#xml_tree_walker">xml_tree_walker</a>+++
+ virtual bool +++<a href="#xml_tree_walker::begin">begin</a>+++(xml_node& node);
+ virtual bool +++<a href="#xml_tree_walker::for_each">for_each</a>+++(xml_node& node) = 0;
+ virtual bool +++<a href="#xml_tree_walker::end">end</a>+++(xml_node& node);
+
+ int +++<a href="#xml_tree_walker::depth">depth</a>+++() const;
+
++++<span class="tok-k">class</span> <a href="#xml_text">xml_text</a>+++
+ bool +++<a href="#xml_text::empty">empty</a>+++() const;
+ operator +++<a href="#xml_text::unspecified_bool_type">xml_text::unspecified_bool_type</a>+++() const;
+
+ const char_t* +++<a href="#xml_text::get">xml_text::get</a>+++() const;
+
+ const char_t* +++<a href="#xml_text::as_string">as_string</a>+++(const char_t* def = "") const;
+ int +++<a href="#xml_text::as_int">as_int</a>+++(int def = 0) const;
+ unsigned int +++<a href="#xml_text::as_uint">as_uint</a>+++(unsigned int def = 0) const;
+ double +++<a href="#xml_text::as_double">as_double</a>+++(double def = 0) const;
+ float +++<a href="#xml_text::as_float">as_float</a>+++(float def = 0) const;
+ bool +++<a href="#xml_text::as_bool">as_bool</a>+++(bool def = false) const;
+ long long +++<a href="#xml_text::as_llong">as_llong</a>+++(long long def = 0) const;
+ unsigned long long +++<a href="#xml_text::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
+
+ bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs);
+
+ bool +++<a href="#xml_text::set">set</a>+++(int rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(unsigned int rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(double rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(float rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(bool rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(long long rhs);
+ bool +++<a href="#xml_text::set">set</a>+++(unsigned long long rhs);
+
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(const char_t* rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(int rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(unsigned int rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(double rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(float rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(bool rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(long long rhs);
+ xml_text& +++<a href="#xml_text::assign">operator=</a>+++(unsigned long long rhs);
+
+ xml_node +++<a href="#xml_text::data">data</a>+++() const;
+
++++<span class="tok-k">class</span> <a href="#xml_writer">xml_writer</a>+++
+ virtual void +++<a href="#xml_writer::write">write</a>+++(const void* data, size_t size) = 0;
+
++++<span class="tok-k">class</span> <a href="#xml_writer_file">xml_writer_file</a>+++: public xml_writer
+ +++<a href="#xml_writer_file">xml_writer_file</a>+++(void* file);
+
++++<span class="tok-k">class</span> <a href="#xml_writer_stream">xml_writer_stream</a>+++: public xml_writer
+ +++<a href="#xml_writer_stream">xml_writer_stream</a>+++(std::ostream& stream);
+ +++<a href="#xml_writer_stream">xml_writer_stream</a>+++(std::wostream& stream);
+
++++<span class="tok-k">struct</span> <a href="#xpath_parse_result">xpath_parse_result</a>+++
+ const char* +++<a href="#xpath_parse_result::error">error</a>+++;
+ ptrdiff_t +++<a href="#xpath_parse_result::offset">offset</a>+++;
+
+ operator +++<a href="#xpath_parse_result::bool">bool</a>+++() const;
+ const char* +++<a href="#xpath_parse_result::description">description</a>+++() const;
+
++++<span class="tok-k">class</span> <a href="#xpath_query">xpath_query</a>+++
+ explicit +++<a href="#xpath_query::ctor">xpath_query</a>+++(const char_t* query, xpath_variable_set* variables = 0);
+
+ bool +++<a href="#xpath_query::evaluate_boolean">evaluate_boolean</a>+++(const xpath_node& n) const;
+ double +++<a href="#xpath_query::evaluate_number">evaluate_number</a>+++(const xpath_node& n) const;
+ string_t +++<a href="#xpath_query::evaluate_string">evaluate_string</a>+++(const xpath_node& n) const;
+ size_t +++<a href="#xpath_query::evaluate_string_buffer">evaluate_string</a>+++(char_t* buffer, size_t capacity, const xpath_node& n) const;
+ xpath_node_set +++<a href="#xpath_query::evaluate_node_set">evaluate_node_set</a>+++(const xpath_node& n) const;
+ xpath_node +++<a href="#xpath_query::evaluate_node">evaluate_node</a>+++(const xpath_node& n) const;
+
+ xpath_value_type +++<a href="#xpath_query::return_type">return_type</a>+++() const;
+
+ const xpath_parse_result& +++<a href="#xpath_query::result">result</a>+++() const;
+ operator +++<a href="#xpath_query::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+
++++<span class="tok-k">class</span> <a href="#xpath_exception">xpath_exception</a>+++: public std::exception
+ virtual const char* +++<a href="#xpath_exception::what">what</a>+++() const throw();
+
+ const xpath_parse_result& +++<a href="#xpath_exception::result">result</a>+++() const;
+
++++<span class="tok-k">class</span> <a href="#xpath_node">xpath_node</a>+++
+ +++<a href="#xpath_node::ctor">xpath_node</a>+++();
+ +++<a href="#xpath_node::ctor">xpath_node</a>+++(const xml_node& node);
+ +++<a href="#xpath_node::ctor">xpath_node</a>+++(const xml_attribute& attribute, const xml_node& parent);
+
+ xml_node +++<a href="#xpath_node::node">node</a>+++() const;
+ xml_attribute +++<a href="#xpath_node::attribute">attribute</a>+++() const;
+ xml_node +++<a href="#xpath_node::parent">parent</a>+++() const;
+
+ operator +++<a href="#xpath_node::unspecified_bool_type">unspecified_bool_type</a>+++() const;
+ bool +++<a href="#xpath_node::comparison">operator==</a>+++(const xpath_node& n) const;
+ bool +++<a href="#xpath_node::comparison">operator!=</a>+++(const xpath_node& n) const;
+
++++<span class="tok-k">class</span> <a href="#xpath_node_set">xpath_node_set</a>+++
+ +++<a href="#xpath_node_set::ctor">xpath_node_set</a>+++();
+ +++<a href="#xpath_node_set::ctor">xpath_node_set</a>+++(const_iterator begin, const_iterator end, type_t type = type_unsorted);
+
+ typedef const xpath_node* +++<a href="#xpath_node_set::const_iterator">const_iterator</a>+++;
+ const_iterator +++<a href="#xpath_node_set::begin">begin</a>+++() const;
+ const_iterator +++<a href="#xpath_node_set::end">end</a>+++() const;
+
+ const xpath_node& +++<a href="#xpath_node_set::index">operator[</a>+++](size_t index) const;
+ size_t +++<a href="#xpath_node_set::size">size</a>+++() const;
+ bool +++<a href="#xpath_node_set::empty">empty</a>+++() const;
+
+ xpath_node +++<a href="#xpath_node_set::first">first</a>+++() const;
+
+ enum type_t {+++<a href="#xpath_node_set::type_unsorted">type_unsorted</a>+++, +++<a href="#xpath_node_set::type_sorted">type_sorted</a>+++, +++<a href="#xpath_node_set::type_sorted_reverse">type_sorted_reverse</a>+++};
+ type_t +++<a href="#xpath_node_set::type">type</a>+++() const;
+ void +++<a href="#xpath_node_set::sort">sort</a>+++(bool reverse = false);
+
++++<span class="tok-k">class</span> <a href="#xpath_variable">xpath_variable</a>+++
+ const char_t* +++<a href="#xpath_variable::name">name</a>+++() const;
+ xpath_value_type +++<a href="#xpath_variable::type">type</a>+++() const;
+
+ bool +++<a href="#xpath_variable::get_boolean">get_boolean</a>+++() const;
+ double +++<a href="#xpath_variable::get_number">get_number</a>+++() const;
+ const char_t* +++<a href="#xpath_variable::get_string">get_string</a>+++() const;
+ const xpath_node_set& +++<a href="#xpath_variable::get_node_set">get_node_set</a>+++() const;
+
+ bool +++<a href="#xpath_variable::set">set</a>+++(bool value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(double value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(const char_t* value);
+ bool +++<a href="#xpath_variable::set">set</a>+++(const xpath_node_set& value);
+
++++<span class="tok-k">class</span> <a href="#xpath_variable_set">xpath_variable_set</a>+++
+ xpath_variable* +++<a href="#xpath_variable_set::add">add</a>+++(const char_t* name, xpath_value_type type);
+
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, bool value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, double value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, const char_t* value);
+ bool +++<a href="#xpath_variable_set::set">set</a>+++(const char_t* name, const xpath_node_set& value);
+
+ xpath_variable* +++<a href="#xpath_variable_set::get">get</a>+++(const char_t* name);
+ const xpath_variable* +++<a href="#xpath_variable_set::get">get</a>+++(const char_t* name) const;
+----
+
+[[apiref.functions]]
+=== Functions
+
+[source,subs="+macros"]
+----
+std::string +++<a href="#as_utf8">as_utf8</a>+++(const wchar_t* str);
+std::string +++<a href="#as_utf8">as_utf8</a>+++(const std::wstring& str);
+std::wstring +++<a href="#as_wide">as_wide</a>+++(const char* str);
+std::wstring +++<a href="#as_wide">as_wide</a>+++(const std::string& str);
+void +++<a href="#set_memory_management_functions">set_memory_management_functions</a>+++(allocation_function allocate, deallocation_function deallocate);
+allocation_function +++<a href="#get_memory_allocation_function">get_memory_allocation_function</a>+++();
+deallocation_function +++<a href="#get_memory_deallocation_function">get_memory_deallocation_function</a>+++();
+----
diff --git a/docs/manual.html b/docs/manual.html
index 0eb13b9..99cc654 100644
--- a/docs/manual.html
+++ b/docs/manual.html
@@ -1,205 +1,5516 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>pugixml 1.5</title>
-<link rel="stylesheet" href="pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="manual.html" title="pugixml 1.5">
-<link rel="next" href="manual/install.html" title="Installation">
+<meta charset="UTF-8">
+<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 1.5.2">
+<meta name="author" content="website, repository">
+<title>pugixml 1.6 manual</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400">
+<style>
+/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
+/* Remove the comments around the @import statement below when using this as a custom stylesheet */
+/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400";*/
+article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
+audio,canvas,video{display:inline-block}
+audio:not([controls]){display:none;height:0}
+[hidden],template{display:none}
+script{display:none!important}
+html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
+body{margin:0}
+a{background:transparent}
+a:focus{outline:thin dotted}
+a:active,a:hover{outline:0}
+h1{font-size:2em;margin:.67em 0}
+abbr[title]{border-bottom:1px dotted}
+b,strong{font-weight:bold}
+dfn{font-style:italic}
+hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
+mark{background:#ff0;color:#000}
+code,kbd,pre,samp{font-family:monospace;font-size:1em}
+pre{white-space:pre-wrap}
+q{quotes:"\201C" "\201D" "\2018" "\2019"}
+small{font-size:80%}
+sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
+sup{top:-.5em}
+sub{bottom:-.25em}
+img{border:0}
+svg:not(:root){overflow:hidden}
+figure{margin:0}
+fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
+legend{border:0;padding:0}
+button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
+button,input{line-height:normal}
+button,select{text-transform:none}
+button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
+button[disabled],html input[disabled]{cursor:default}
+input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
+input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}
+input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}
+button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
+textarea{overflow:auto;vertical-align:top}
+table{border-collapse:collapse;border-spacing:0}
+*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
+html,body{font-size:100%}
+body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto}
+a:hover{cursor:pointer}
+img,object,embed{max-width:100%;height:auto}
+object,embed{height:100%}
+img{-ms-interpolation-mode:bicubic}
+#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none!important}
+.left{float:left!important}
+.right{float:right!important}
+.text-left{text-align:left!important}
+.text-right{text-align:right!important}
+.text-center{text-align:center!important}
+.text-justify{text-align:justify!important}
+.hide{display:none}
+.antialiased,body{-webkit-font-smoothing:antialiased}
+img{display:inline-block;vertical-align:middle}
+textarea{height:auto;min-height:50px}
+select{width:100%}
+p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6}
+.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
+div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
+a{color:#2156a5;text-decoration:underline;line-height:inherit}
+a:hover,a:focus{color:#1d4b8f}
+a img{border:none}
+p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
+p aside{font-size:.875em;line-height:1.35;font-style:italic}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
+h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
+h1{font-size:2.125em}
+h2{font-size:1.6875em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
+h4,h5{font-size:1.125em}
+h6{font-size:1em}
+hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
+em,i{font-style:italic;line-height:inherit}
+strong,b{font-weight:bold;line-height:inherit}
+small{font-size:60%;line-height:inherit}
+code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
+ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
+ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em}
+ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
+ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
+ul.square{list-style-type:square}
+ul.circle{list-style-type:circle}
+ul.disc{list-style-type:disc}
+ul.no-bullet{list-style:none}
+ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
+dl dt{margin-bottom:.3125em;font-weight:bold}
+dl dd{margin-bottom:1.25em}
+abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
+abbr{text-transform:none}
+blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
+blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
+blockquote cite:before{content:"\2014 \0020"}
+blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
+blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
+@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
+h1{font-size:2.75em}
+h2{font-size:2.3125em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
+h4{font-size:1.4375em}}table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
+table thead,table tfoot{background:#f7f8f7;font-weight:bold}
+table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
+table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
+table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
+table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
+h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
+.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table}
+.clearfix:after,.float-group:after{clear:both}
+*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
+pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
+.keyseq{color:rgba(51,51,51,.8)}
+kbd{display:inline-block;color:rgba(0,0,0,.8);font-size:.75em;line-height:1.4;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:-.15em .15em 0 .15em;padding:.2em .6em .2em .5em;vertical-align:middle;white-space:nowrap}
+.keyseq kbd:first-child{margin-left:0}
+.keyseq kbd:last-child{margin-right:0}
+.menuseq,.menu{color:rgba(0,0,0,.8)}
+b.button:before,b.button:after{position:relative;top:-1px;font-weight:400}
+b.button:before{content:"[";padding:0 3px 0 2px}
+b.button:after{content:"]";padding:0 2px 0 3px}
+p a>code:hover{color:rgba(0,0,0,.9)}
+#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
+#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table}
+#header:after,#content:after,#footnotes:after,#footer:after{clear:both}
+#content{margin-top:1.25em}
+#content:before{content:none}
+#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
+#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8}
+#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px}
+#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
+#header .details span:first-child{margin-left:-.125em}
+#header .details span.email a{color:rgba(0,0,0,.85)}
+#header .details br{display:none}
+#header .details br+span:before{content:"\00a0\2013\00a0"}
+#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
+#header .details br+span#revremark:before{content:"\00a0|\00a0"}
+#header #revnumber{text-transform:capitalize}
+#header #revnumber:after{content:"\00a0"}
+#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
+#toc{border-bottom:1px solid #efefed;padding-bottom:.5em}
+#toc>ul{margin-left:.125em}
+#toc ul.sectlevel0>li>a{font-style:italic}
+#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
+#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
+#toc a{text-decoration:none}
+#toc a:active{text-decoration:underline}
+#toctitle{color:#7a2518;font-size:1.2em}
+@media only screen and (min-width:768px){#toctitle{font-size:1.375em}
+body.toc2{padding-left:15em;padding-right:0}
+#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
+#toc.toc2 #toctitle{margin-top:0;font-size:1.2em}
+#toc.toc2>ul{font-size:.9em;margin-bottom:0}
+#toc.toc2 ul ul{margin-left:0;padding-left:1em}
+#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
+body.toc2.toc-right{padding-left:0;padding-right:15em}
+body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}}@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
+#toc.toc2{width:20em}
+#toc.toc2 #toctitle{font-size:1.375em}
+#toc.toc2>ul{font-size:.95em}
+#toc.toc2 ul ul{padding-left:1.25em}
+body.toc2.toc-right{padding-left:0;padding-right:20em}}#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
+#content #toc>:first-child{margin-top:0}
+#content #toc>:last-child{margin-bottom:0}
+#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
+#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
+.sect1{padding-bottom:.625em}
+@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}}.sect1+.sect1{border-top:1px solid #efefed}
+#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
+#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
+#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
+#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
+#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
+.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
+.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
+table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0}
+.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)}
+table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit}
+.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
+.admonitionblock>table td.icon{text-align:center;width:80px}
+.admonitionblock>table td.icon img{max-width:none}
+.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
+.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)}
+.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
+.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
+.exampleblock>.content>:first-child{margin-top:0}
+.exampleblock>.content>:last-child{margin-bottom:0}
+.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
+.sidebarblock>:first-child{margin-top:0}
+.sidebarblock>:last-child{margin-bottom:0}
+.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
+.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
+.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
+.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
+.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em}
+.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal}
+@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
+.listingblock pre.highlightjs{padding:0}
+.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
+.listingblock pre.prettyprint{border-width:0}
+.listingblock>.content{position:relative}
+.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
+.listingblock:hover code[data-lang]:before{display:block}
+.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999}
+.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"}
+table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
+table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0}
+table.pyhltable td.code{padding-left:.75em;padding-right:0}
+pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8}
+pre.pygments .lineno{display:inline-block;margin-right:.25em}
+table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
+.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
+.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
+.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
+.quoteblock blockquote{margin:0;padding:0;border:0}
+.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
+.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
+.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right}
+.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)}
+.quoteblock .quoteblock blockquote{padding:0 0 0 .75em}
+.quoteblock .quoteblock blockquote:before{display:none}
+.verseblock{margin:0 1em 1.25em 1em}
+.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
+.verseblock pre strong{font-weight:400}
+.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
+.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
+.quoteblock .attribution br,.verseblock .attribution br{display:none}
+.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.05em;color:rgba(0,0,0,.6)}
+.quoteblock.abstract{margin:0 0 1.25em 0;display:block}
+.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0}
+.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none}
+table.tableblock{max-width:100%;border-collapse:separate}
+table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0}
+table.spread{width:100%}
+table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
+table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0}
+table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0}
+table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0}
+table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0}
+table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0}
+table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0}
+table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0}
+table.frame-all{border-width:1px}
+table.frame-sides{border-width:0 1px}
+table.frame-topbot{border-width:1px 0}
+th.halign-left,td.halign-left{text-align:left}
+th.halign-right,td.halign-right{text-align:right}
+th.halign-center,td.halign-center{text-align:center}
+th.valign-top,td.valign-top{vertical-align:top}
+th.valign-bottom,td.valign-bottom{vertical-align:bottom}
+th.valign-middle,td.valign-middle{vertical-align:middle}
+table thead th,table tfoot th{font-weight:bold}
+tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
+tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
+p.tableblock>code:only-child{background:none;padding:0}
+p.tableblock{font-size:1em}
+td>div.verse{white-space:pre}
+ol{margin-left:1.75em}
+ul li ol{margin-left:1.5em}
+dl dd{margin-left:1.125em}
+dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
+ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
+ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none}
+ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em}
+ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em}
+ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px}
+ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden}
+ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block}
+ul.inline>li>*{display:block}
+.unstyled dl dt{font-weight:400;font-style:normal}
+ol.arabic{list-style-type:decimal}
+ol.decimal{list-style-type:decimal-leading-zero}
+ol.loweralpha{list-style-type:lower-alpha}
+ol.upperalpha{list-style-type:upper-alpha}
+ol.lowerroman{list-style-type:lower-roman}
+ol.upperroman{list-style-type:upper-roman}
+ol.lowergreek{list-style-type:lower-greek}
+.hdlist>table,.colist>table{border:0;background:none}
+.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
+td.hdlist1{padding-right:.75em;font-weight:bold}
+td.hdlist1,td.hdlist2{vertical-align:top}
+.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
+.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1}
+.colist>table tr>td:last-of-type{padding:.25em 0}
+.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
+.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0}
+.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em}
+.imageblock>.title{margin-bottom:0}
+.imageblock.thumb,.imageblock.th{border-width:6px}
+.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
+.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
+.image.left{margin-right:.625em}
+.image.right{margin-left:.625em}
+a.image{text-decoration:none}
+span.footnote,span.footnoteref{vertical-align:super;font-size:.875em}
+span.footnote a,span.footnoteref a{text-decoration:none}
+span.footnote a:active,span.footnoteref a:active{text-decoration:underline}
+#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
+#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0}
+#footnotes .footnote{padding:0 .375em;line-height:1.3;font-size:.875em;margin-left:1.2em;text-indent:-1.2em;margin-bottom:.2em}
+#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none}
+#footnotes .footnote:last-of-type{margin-bottom:0}
+#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
+.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
+.gist .file-data>table td.line-data{width:99%}
+div.unbreakable{page-break-inside:avoid}
+.big{font-size:larger}
+.small{font-size:smaller}
+.underline{text-decoration:underline}
+.overline{text-decoration:overline}
+.line-through{text-decoration:line-through}
+.aqua{color:#00bfbf}
+.aqua-background{background-color:#00fafa}
+.black{color:#000}
+.black-background{background-color:#000}
+.blue{color:#0000bf}
+.blue-background{background-color:#0000fa}
+.fuchsia{color:#bf00bf}
+.fuchsia-background{background-color:#fa00fa}
+.gray{color:#606060}
+.gray-background{background-color:#7d7d7d}
+.green{color:#006000}
+.green-background{background-color:#007d00}
+.lime{color:#00bf00}
+.lime-background{background-color:#00fa00}
+.maroon{color:#600000}
+.maroon-background{background-color:#7d0000}
+.navy{color:#000060}
+.navy-background{background-color:#00007d}
+.olive{color:#606000}
+.olive-background{background-color:#7d7d00}
+.purple{color:#600060}
+.purple-background{background-color:#7d007d}
+.red{color:#bf0000}
+.red-background{background-color:#fa0000}
+.silver{color:#909090}
+.silver-background{background-color:#bcbcbc}
+.teal{color:#006060}
+.teal-background{background-color:#007d7d}
+.white{color:#bfbfbf}
+.white-background{background-color:#fafafa}
+.yellow{color:#bfbf00}
+.yellow-background{background-color:#fafa00}
+span.icon>.fa{cursor:default}
+.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
+.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c}
+.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
+.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900}
+.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400}
+.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000}
+.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
+.conum[data-value] *{color:#fff!important}
+.conum[data-value]+b{display:none}
+.conum[data-value]:after{content:attr(data-value)}
+pre .conum[data-value]{position:relative;top:-.125em}
+b.conum *{color:inherit!important}
+.conum:not([data-value]):empty{display:none}
+h1,h2{letter-spacing:-.01em}
+dt,th.tableblock,td.content{text-rendering:optimizeLegibility}
+p,td.content{letter-spacing:-.01em}
+p strong,td.content strong{letter-spacing:-.005em}
+p,blockquote,dt,td.content{font-size:1.0625rem}
+p{margin-bottom:1.25rem}
+.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
+.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
+.print-only{display:none!important}
+@media print{@page{margin:1.25cm .75cm}
+*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
+a{color:inherit!important;text-decoration:underline!important}
+a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
+a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
+abbr[title]:after{content:" (" attr(title) ")"}
+pre,blockquote,tr,img{page-break-inside:avoid}
+thead{display:table-header-group}
+img{max-width:100%!important}
+p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
+h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
+#toc,.sidebarblock,.exampleblock>.content{background:none!important}
+#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important}
+.sect1{padding-bottom:0!important}
+.sect1+.sect1{border:0!important}
+#header>h1:first-child{margin-top:1.25rem}
+body.book #header{text-align:center}
+body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0}
+body.book #header .details{border:0!important;display:block;padding:0!important}
+body.book #header .details span:first-child{margin-left:0!important}
+body.book #header .details br{display:block}
+body.book #header .details br+span:before{content:none!important}
+body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
+body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
+.listingblock code[data-lang]:before{display:block}
+#footer{background:none!important;padding:0 .9375em}
+#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em}
+.hide-on-print{display:none!important}
+.print-only{display:block!important}
+.hide-for-print{display:none!important}
+.show-for-print{display:inherit!important}}
+</style>
+<style>
+.listingblock .pygments .hll { background-color: #ffffcc }
+.listingblock .pygments { background: #f8f8f8; }
+.listingblock .pygments .tok-c { color: #408080; font-style: italic } /* Comment */
+.listingblock .pygments .tok-err { border: 1px solid #FF0000 } /* Error */
+.listingblock .pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */
+.listingblock .pygments .tok-o { color: #666666 } /* Operator */
+.listingblock .pygments .tok-cm { color: #408080; font-style: italic } /* Comment.Multiline */
+.listingblock .pygments .tok-cp { color: #BC7A00 } /* Comment.Preproc */
+.listingblock .pygments .tok-c1 { color: #408080; font-style: italic } /* Comment.Single */
+.listingblock .pygments .tok-cs { color: #408080; font-style: italic } /* Comment.Special */
+.listingblock .pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
+.listingblock .pygments .tok-ge { font-style: italic } /* Generic.Emph */
+.listingblock .pygments .tok-gr { color: #FF0000 } /* Generic.Error */
+.listingblock .pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.listingblock .pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
+.listingblock .pygments .tok-go { color: #888888 } /* Generic.Output */
+.listingblock .pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.listingblock .pygments .tok-gs { font-weight: bold } /* Generic.Strong */
+.listingblock .pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.listingblock .pygments .tok-gt { color: #0044DD } /* Generic.Traceback */
+.listingblock .pygments .tok-kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.listingblock .pygments .tok-kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.listingblock .pygments .tok-kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.listingblock .pygments .tok-kp { color: #008000 } /* Keyword.Pseudo */
+.listingblock .pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.listingblock .pygments .tok-kt { color: #B00040 } /* Keyword.Type */
+.listingblock .pygments .tok-m { color: #666666 } /* Literal.Number */
+.listingblock .pygments .tok-s { color: #BA2121 } /* Literal.String */
+.listingblock .pygments .tok-na { color: #7D9029 } /* Name.Attribute */
+.listingblock .pygments .tok-nb { color: #008000 } /* Name.Builtin */
+.listingblock .pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */
+.listingblock .pygments .tok-no { color: #880000 } /* Name.Constant */
+.listingblock .pygments .tok-nd { color: #AA22FF } /* Name.Decorator */
+.listingblock .pygments .tok-ni { color: #999999; font-weight: bold } /* Name.Entity */
+.listingblock .pygments .tok-ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.listingblock .pygments .tok-nf { color: #0000FF } /* Name.Function */
+.listingblock .pygments .tok-nl { color: #A0A000 } /* Name.Label */
+.listingblock .pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.listingblock .pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */
+.listingblock .pygments .tok-nv { color: #19177C } /* Name.Variable */
+.listingblock .pygments .tok-ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.listingblock .pygments .tok-w { color: #bbbbbb } /* Text.Whitespace */
+.listingblock .pygments .tok-mb { color: #666666 } /* Literal.Number.Bin */
+.listingblock .pygments .tok-mf { color: #666666 } /* Literal.Number.Float */
+.listingblock .pygments .tok-mh { color: #666666 } /* Literal.Number.Hex */
+.listingblock .pygments .tok-mi { color: #666666 } /* Literal.Number.Integer */
+.listingblock .pygments .tok-mo { color: #666666 } /* Literal.Number.Oct */
+.listingblock .pygments .tok-sb { color: #BA2121 } /* Literal.String.Backtick */
+.listingblock .pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */
+.listingblock .pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
+.listingblock .pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */
+.listingblock .pygments .tok-se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.listingblock .pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */
+.listingblock .pygments .tok-si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.listingblock .pygments .tok-sx { color: #008000 } /* Literal.String.Other */
+.listingblock .pygments .tok-sr { color: #BB6688 } /* Literal.String.Regex */
+.listingblock .pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */
+.listingblock .pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */
+.listingblock .pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */
+.listingblock .pygments .tok-vc { color: #19177C } /* Name.Variable.Class */
+.listingblock .pygments .tok-vg { color: #19177C } /* Name.Variable.Global */
+.listingblock .pygments .tok-vi { color: #19177C } /* Name.Variable.Instance */
+.listingblock .pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
+</style>
</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <b>Overview</b> |
- <a href="manual/install.html">Installation</a> |
- Document:
- <a href="manual/dom.html">Object model</a> &middot; <a href="manual/loading.html">Loading</a> &middot; <a href="manual/access.html">Accessing</a> &middot; <a href="manual/modify.html">Modifying</a> &middot; <a href="manual/saving.html">Saving</a> |
- <a href="manual/xpath.html">XPath</a> |
- <a href="manual/apiref.html">API Reference</a> |
- <a href="manual/toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav"><a accesskey="n" href="manual/install.html"><img src="images/next.png" alt="Next"></a></div></td>
-</tr></table>
-<hr>
-<div class="book"><div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.overview"></a><a class="link" href="manual.html#manual.overview" title="Overview"> Overview</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="manual.html#manual.overview.introduction"> Introduction</a></span></dt>
-<dt><span class="section"><a href="manual.html#manual.overview.feedback"> Feedback</a></span></dt>
-<dt><span class="section"><a href="manual.html#manual.overview.thanks"> Acknowledgments</a></span></dt>
-<dt><span class="section"><a href="manual.html#manual.overview.license"> License</a></span></dt>
-</dl></div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.overview.introduction"></a><a class="link" href="manual.html#manual.overview.introduction" title="Introduction"> Introduction</a>
-</h3></div></div></div>
-<p>
- <a href="http://pugixml.org/" target="_top">pugixml</a> is a light-weight C++ XML
- processing library. It consists of a DOM-like interface with rich traversal/modification
- capabilities, an extremely fast XML parser which constructs the DOM tree
- from an XML file/buffer, and an <a class="link" href="manual/xpath.html" title="XPath">XPath 1.0 implementation</a>
- for complex data-driven tree queries. Full Unicode support is also available,
- with <a class="link" href="manual/dom.html#manual.dom.unicode" title="Unicode interface">two Unicode interface variants</a>
- and conversions between different Unicode encodings (which happen automatically
- during parsing/saving). The library is <a class="link" href="manual/install.html#manual.install.portability" title="Portability">extremely
- portable</a> and easy to integrate and use. pugixml is developed and maintained
- since 2006 and has many users. All code is distributed under the <a class="link" href="manual.html#manual.overview.license" title="License">MIT
- license</a>, making it completely free to use in both open-source and
- proprietary applications.
- </p>
-<p>
- pugixml enables very fast, convenient and memory-efficient XML document processing.
- However, since pugixml has a DOM parser, it can't process XML documents that
- do not fit in memory; also the parser is a non-validating one, so if you
- need DTD or XML Schema validation, the library is not for you.
- </p>
-<p>
- This is the complete manual for pugixml, which describes all features of
- the library in detail. If you want to start writing code as quickly as possible,
- you are advised to <a href="quickstart.html" target="_top">read the quick start guide
- first</a>.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- No documentation is perfect, neither is this one. If you encounter a description
- that is unclear, please file an issue as described in <a class="xref" href="manual.html#manual.overview.feedback" title="Feedback"> Feedback</a>.
- Also if you can spare the time for a full proof-reading, including spelling
- and grammar, that would be great! Please <a class="link" href="manual.html#email">send me
- an e-mail</a>; as a token of appreciation, your name will be included
- into the <a class="link" href="manual.html#manual.overview.thanks" title="Acknowledgments">corresponding section</a>
- of this documentation.
- </p></td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.overview.feedback"></a><a class="link" href="manual.html#manual.overview.feedback" title="Feedback"> Feedback</a>
-</h3></div></div></div>
-<p>
- If you believe you've found a bug in pugixml (bugs include compilation problems
- (errors/warnings), crashes, performance degradation and incorrect behavior),
- please file an issue via <a href="http://code.google.com/p/pugixml/issues/entry" target="_top">issue
- submission form</a>. Be sure to include the relevant information so that
- the bug can be reproduced: the version of pugixml, compiler version and target
- architecture, the code that uses pugixml and exhibits the bug, etc.
- </p>
-<p>
- Feature requests can be reported the same way as bugs, so if you're missing
- some functionality in pugixml or if the API is rough in some places and you
- can suggest an improvement, <a href="http://code.google.com/p/pugixml/issues/entry?template=Feature%20request" target="_top">file
- an issue</a>. However please note that there are many factors when considering
- API changes (compatibility with previous versions, API redundancy, etc.),
- so generally features that can be implemented via a small function without
- pugixml modification are not accepted. However, all rules have exceptions.
- </p>
-<p>
- If you have a contribution to pugixml, such as build script for some build
- system/IDE, or a well-designed set of helper functions, or a binding to some
- language other than C++, please <a href="http://code.google.com/p/pugixml/issues/entry?template=Feature%20request" target="_top">file
- an issue</a>. You can include the relevant patches as issue attachments.
- Your contribution has to be distributed under the terms of a license that's
- compatible with pugixml license; i.e. GPL/LGPL licensed code is not accepted.
- </p>
-<a name="email"></a><p>
- If filing an issue is not possible due to privacy or other concerns, you
- can contact pugixml author by e-mail directly: <a href="mailto:arseny.kapoulkine@gmail.com" target="_top">arseny.kapoulkine@gmail.com</a>.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.overview.thanks"></a><a class="link" href="manual.html#manual.overview.thanks" title="Acknowledgments"> Acknowledgments</a>
-</h3></div></div></div>
-<p>
- pugixml could not be developed without the help from many people; some of
- them are listed in this section. If you've played a part in pugixml development
- and you can not find yourself on this list, I'm truly sorry; please <a class="link" href="manual.html#email">send me an e-mail</a> so I can fix this.
- </p>
-<p>
- Thanks to <span class="bold"><strong>Kristen Wegner</strong></span> for pugxml parser,
- which was used as a basis for pugixml.
- </p>
-<p>
- Thanks to <span class="bold"><strong>Neville Franks</strong></span> for contributions
- to pugxml parser.
- </p>
-<p>
- Thanks to <span class="bold"><strong>Artyom Palvelev</strong></span> for suggesting
- a lazy gap contraction approach.
- </p>
-<p>
- Thanks to <span class="bold"><strong>Vyacheslav Egorov</strong></span> for documentation
- proofreading.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.overview.license"></a><a class="link" href="manual.html#manual.overview.license" title="License"> License</a>
-</h3></div></div></div>
-<p>
- The pugixml library is distributed under the MIT license:
- </p>
-<div class="blockquote"><blockquote class="blockquote">
-<p>
- Copyright (c) 2006-2014 Arseny Kapoulkine
- </p>
-<p>
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the Software
- is furnished to do so, subject to the following conditions:
- </p>
-<p>
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
- </p>
-<p>
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- IN THE SOFTWARE.
- </p>
-</blockquote></div>
-<p>
- This means that you can freely use pugixml in your applications, both open-source
- and proprietary. If you use pugixml in a product, it is sufficient to add
- an acknowledgment like this to the product distribution:
- </p>
-<div class="blockquote"><blockquote class="blockquote"><p>
- This software is based on pugixml library (http://pugixml.org).<br>
-pugixml
- is Copyright (C) 2006-2014 Arseny Kapoulkine.
- </p></blockquote></div>
-</div>
-</div></div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: November 26, 2014 at 02:23:21 GMT</small></p></td>
-<td align="right"><div class="copyright-footer"></div></td>
-</tr></table>
+<body class="article toc2 toc-right">
+<div id="header">
+<h1>pugixml 1.6 manual</h1>
+<div class="details">
+<span id="author" class="author">website</span><br>
+<span id="email" class="email"><a href="http://pugixml.org" class="bare">http://pugixml.org</a></span><br>
+<span id="author2" class="author">repository</span><br>
+<span id="email2" class="email"><a href="http://github.com/zeux/pugixml" class="bare">http://github.com/zeux/pugixml</a></span><br>
+</div>
+<div id="toc" class="toc2">
+<div id="toctitle">Table of Contents</div>
+<ul class="sectlevel1">
+<li><a href="#overview">1. Overview</a>
+<ul class="sectlevel2">
+<li><a href="#overview.introduction">1.1. Introduction</a></li>
+<li><a href="#overview.feedback">1.2. Feedback</a></li>
+<li><a href="#overview.thanks">1.3. Acknowledgments</a></li>
+<li><a href="#overview.license">1.4. License</a></li>
+</ul>
+</li>
+<li><a href="#install">2. Installation</a>
+<ul class="sectlevel2">
+<li><a href="#install.getting">2.1. Getting pugixml</a></li>
+<li><a href="#install.building">2.2. Building pugixml</a></li>
+<li><a href="#install.portability">2.3. Portability</a></li>
+</ul>
+</li>
+<li><a href="#dom">3. Document object model</a>
+<ul class="sectlevel2">
+<li><a href="#dom.tree">3.1. Tree structure</a></li>
+<li><a href="#dom.cpp">3.2. C&#43;&#43; interface</a></li>
+<li><a href="#dom.unicode">3.3. Unicode interface</a></li>
+<li><a href="#dom.thread">3.4. Thread-safety guarantees</a></li>
+<li><a href="#dom.exception">3.5. Exception guarantees</a></li>
+<li><a href="#dom.memory">3.6. Memory management</a></li>
+</ul>
+</li>
+<li><a href="#loading">4. Loading document</a>
+<ul class="sectlevel2">
+<li><a href="#loading.file">4.1. Loading document from file</a></li>
+<li><a href="#loading.memory">4.2. Loading document from memory</a></li>
+<li><a href="#loading.stream">4.3. Loading document from C&#43;&#43; IOstreams</a></li>
+<li><a href="#loading.errors">4.4. Handling parsing errors</a></li>
+<li><a href="#loading.options">4.5. Parsing options</a></li>
+<li><a href="#loading.encoding">4.6. Encodings</a></li>
+<li><a href="#loading.w3c">4.7. Conformance to W3C specification</a></li>
+</ul>
+</li>
+<li><a href="#access">5. Accessing document data</a>
+<ul class="sectlevel2">
+<li><a href="#access.basic">5.1. Basic traversal functions</a></li>
+<li><a href="#access.nodedata">5.2. Getting node data</a></li>
+<li><a href="#access.attrdata">5.3. Getting attribute data</a></li>
+<li><a href="#access.contents">5.4. Contents-based traversal functions</a></li>
+<li><a href="#access.rangefor">5.5. Range-based for-loop support</a></li>
+<li><a href="#access.iterators">5.6. Traversing node/attribute lists via iterators</a></li>
+<li><a href="#access.walker">5.7. Recursive traversal with xml_tree_walker</a></li>
+<li><a href="#access.predicate">5.8. Searching for nodes/attributes with predicates</a></li>
+<li><a href="#access.text">5.9. Working with text contents</a></li>
+<li><a href="#access.misc">5.10. Miscellaneous functions</a></li>
+</ul>
+</li>
+<li><a href="#modify">6. Modifying document data</a>
+<ul class="sectlevel2">
+<li><a href="#modify.nodedata">6.1. Setting node data</a></li>
+<li><a href="#modify.attrdata">6.2. Setting attribute data</a></li>
+<li><a href="#modify.add">6.3. Adding nodes/attributes</a></li>
+<li><a href="#modify.remove">6.4. Removing nodes/attributes</a></li>
+<li><a href="#modify.text">6.5. Working with text contents</a></li>
+<li><a href="#modify.clone">6.6. Cloning nodes/attributes</a></li>
+<li><a href="#modify.move">6.7. Moving nodes</a></li>
+<li><a href="#modify.fragments">6.8. Assembling document from fragments</a></li>
+</ul>
+</li>
+<li><a href="#saving">7. Saving document</a>
+<ul class="sectlevel2">
+<li><a href="#saving.file">7.1. Saving document to a file</a></li>
+<li><a href="#saving.stream">7.2. Saving document to C&#43;&#43; IOstreams</a></li>
+<li><a href="#saving.writer">7.3. Saving document via writer interface</a></li>
+<li><a href="#saving.subtree">7.4. Saving a single subtree</a></li>
+<li><a href="#saving.options">7.5. Output options</a></li>
+<li><a href="#saving.encoding">7.6. Encodings</a></li>
+<li><a href="#saving.declaration">7.7. Customizing document declaration</a></li>
+</ul>
+</li>
+<li><a href="#xpath">8. XPath</a>
+<ul class="sectlevel2">
+<li><a href="#xpath.types">8.1. XPath types</a></li>
+<li><a href="#xpath.select">8.2. Selecting nodes via XPath expression</a></li>
+<li><a href="#xpath.query">8.3. Using query objects</a></li>
+<li><a href="#xpath.variables">8.4. Using variables</a></li>
+<li><a href="#xpath.errors">8.5. Error handling</a></li>
+<li><a href="#xpath.w3c">8.6. Conformance to W3C specification</a></li>
+</ul>
+</li>
+<li><a href="#changes">9. Changelog</a>
+<ul class="sectlevel2">
+<li><a href="#v1.6">v1.6 <sup>10.04.2015</sup></a></li>
+<li><a href="#v1.5">v1.5 <sup>27.11.2014</sup></a></li>
+<li><a href="#v1.4">v1.4 <sup>27.02.2014</sup></a></li>
+<li><a href="#v1.2">v1.2 <sup>1.05.2012</sup></a></li>
+<li><a href="#v1.0">v1.0 <sup>1.11.2010</sup></a></li>
+<li><a href="#v0.9">v0.9 <sup>1.07.2010</sup></a></li>
+<li><a href="#v0.5">v0.5 <sup>8.11.2009</sup></a></li>
+<li><a href="#v0.42">v0.42 <sup>17.09.2009</sup></a></li>
+<li><a href="#v0.41">v0.41 <sup>8.02.2009</sup></a></li>
+<li><a href="#v0.4">v0.4 <sup>18.01.2009</sup></a></li>
+<li><a href="#v0.34">v0.34 <sup>31.10.2007</sup></a></li>
+<li><a href="#v0.3">v0.3 <sup>21.02.2007</sup></a></li>
+<li><a href="#v0.2">v0.2 <sup>6.11.2006</sup></a></li>
+<li><a href="#v0.1">v0.1 <sup>15.07.2006</sup></a></li>
+</ul>
+</li>
+<li><a href="#apiref">10. API Reference</a>
+<ul class="sectlevel2">
+<li><a href="#apiref.macros">10.1. Macros</a></li>
+<li><a href="#apiref.types">10.2. Types</a></li>
+<li><a href="#apiref.enums">10.3. Enumerations</a></li>
+<li><a href="#apiref.constants">10.4. Constants</a></li>
+<li><a href="#apiref.classes">10.5. Classes</a></li>
+<li><a href="#apiref.functions">10.6. Functions</a></li>
+</ul>
+</li>
+</ul>
+</div>
+</div>
+<div id="content">
+<div class="sect1">
+<h2 id="overview"><a class="anchor" href="#overview"></a>1. Overview</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="overview.introduction"><a class="anchor" href="#overview.introduction"></a>1.1. Introduction</h3>
+<div class="paragraph">
+<p><a href="http://pugixml.org/">pugixml</a> is a light-weight C&#43;&#43; XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an <a href="#xpath">XPath 1.0 implementation</a> for complex data-driven tree queries. Full Unicode support is also available, with <a href="#dom.unicode">two Unicode interface variants</a> and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is <a href="#install.portability">extremely portable</a> and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the <a href="#overview.license">MIT license</a>, making it completely free to use in both open-source and proprietary applications.</p>
+</div>
+<div class="paragraph">
+<p>pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can&#8217;t process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD or XML Schema validation, the library is not for you.</p>
+</div>
+<div class="paragraph">
+<p>This is the complete manual for pugixml, which describes all features of the library in detail. If you want to start writing code as quickly as possible, you are advised to <a href="quickstart.html">read the quick start guide first</a>.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to <a href="https://github.com/zeux/pugixml/issues/new">submit an issue or open a pull request</a> with a fix.
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="overview.feedback"><a class="anchor" href="#overview.feedback"></a>1.2. Feedback</h3>
+<div class="paragraph">
+<p>If you believe you&#8217;ve found a bug in pugixml (bugs include compilation problems (errors/warnings), crashes, performance degradation and incorrect behavior), please file an issue via <a href="https://github.com/zeux/pugixml/issues/new">issue submission form</a>. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc.</p>
+</div>
+<div class="paragraph">
+<p>Feature requests can be reported the same way as bugs, so if you&#8217;re missing some functionality in pugixml or if the API is rough in some places and you can suggest an improvement, <a href="https://github.com/zeux/pugixml/issues/new">file an issue</a>. However please note that there are many factors when considering API changes (compatibility with previous versions, API redundancy, etc.), so generally features that can be implemented via a small function without pugixml modification are not accepted. However, all rules have exceptions.</p>
+</div>
+<div class="paragraph">
+<p>If you have a contribution to pugixml, such as build script for some build system/IDE, or a well-designed set of helper functions, or a binding to some language other than C&#43;&#43;, please <a href="https://github.com/zeux/pugixml/issues/new">file an issue or open a pull request</a>. Your contribution has to be distributed under the terms of a license that&#8217;s compatible with pugixml license; i.e. GPL/LGPL licensed code is not accepted.</p>
+</div>
+<div class="paragraph">
+<p>If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: <a href="mailto:arseny.kapoulkine@gmail.com">arseny.kapoulkine@gmail.com</a>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="overview.thanks"><a class="anchor" href="#overview.thanks"></a>1.3. Acknowledgments</h3>
+<div class="paragraph">
+<p>pugixml could not be developed without the help from many people; some of them are listed in this section. If you&#8217;ve played a part in pugixml development and you can not find yourself on this list, I&#8217;m truly sorry; please <a href="#email">send me an e-mail</a> so I can fix this.</p>
+</div>
+<div class="paragraph">
+<p>Thanks to <strong>Kristen Wegner</strong> for pugxml parser, which was used as a basis for pugixml.</p>
+</div>
+<div class="paragraph">
+<p>Thanks to <strong>Neville Franks</strong> for contributions to pugxml parser.</p>
+</div>
+<div class="paragraph">
+<p>Thanks to <strong>Artyom Palvelev</strong> for suggesting a lazy gap contraction approach.</p>
+</div>
+<div class="paragraph">
+<p>Thanks to <strong>Vyacheslav Egorov</strong> for documentation proofreading.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="overview.license"><a class="anchor" href="#overview.license"></a>1.4. License</h3>
+<div class="paragraph">
+<p>The pugixml library is distributed under the MIT license:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Copyright (c) 2006-2015 Arseny Kapoulkine
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>This software is based on pugixml library (http://pugixml.org).
+pugixml is Copyright (C) 2006-2015 Arseny Kapoulkine.</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="install"><a class="anchor" href="#install"></a>2. Installation</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="install.getting"><a class="anchor" href="#install.getting"></a>2.1. Getting pugixml</h3>
+<div class="paragraph">
+<p>pugixml is distributed in source form. You can either download a source distribution or clone the Git repository.</p>
+</div>
+<div class="sect3">
+<h4 id="install.getting.source"><a class="anchor" href="#install.getting.source"></a>2.1.1. Source distributions</h4>
+<div class="paragraph">
+<p>You can download the latest source distribution as an archive:</p>
+</div>
+<div class="paragraph">
+<p><a href="https://github.com/zeux/pugixml/releases/download/v1.6/pugixml-1.6.zip">pugixml-1.6.zip</a> (Windows line endings)
+/
+<a href="https://github.com/zeux/pugixml/releases/download/v1.6/pugixml-1.6.tar.gz">pugixml-1.6.tar.gz</a> (Unix line endings)</p>
+</div>
+<div class="paragraph">
+<p>The distribution contains library source, documentation (the manual you&#8217;re reading now and the quick start guide) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.</p>
+</div>
+<div class="paragraph">
+<p>If you need an older version, you can download it from the <a href="https://github.com/zeux/pugixml/releases">version archive</a>.</p>
+</div>
+</div>
+<div class="sect3">
+<h4 id="install.getting.git"><a class="anchor" href="#install.getting.git"></a>2.1.2. Git repository</h4>
+<div class="paragraph">
+<p>The Git repository is located at <a href="https://github.com/zeux/pugixml/" class="bare">https://github.com/zeux/pugixml/</a>. There is a Git tag "v{version}" for each version; also there is the "latest" tag, which always points to the latest stable release.</p>
+</div>
+<div class="paragraph">
+<p>For example, to checkout the current version, you can use this command:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="bash">git clone https://github.com/zeux/pugixml
+cd pugixml
+git checkout v1.6</code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The repository contains library source, documentation, code examples and full unit test suite.</p>
+</div>
+<div class="paragraph">
+<p>Use <code>latest</code> tag if you want to automatically get new versions. Use other tags if you want to switch to new versions only explicitly. Also please note that the master branch contains the work-in-progress version of the code; while this means that you can get new features and bug fixes from master without waiting for a new release, this also means that occasionally the code can be broken in some configurations.</p>
+</div>
+</div>
+<div class="sect3">
+<h4 id="install.getting.subversion"><a class="anchor" href="#install.getting.subversion"></a>2.1.3. Subversion repository</h4>
+<div class="paragraph">
+<p>You can access the Git repository via Subversion using <a href="https://github.com/zeux/pugixml" class="bare">https://github.com/zeux/pugixml</a> URL. For example, to checkout the current version, you can use this command:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="bash">svn checkout https://github.com/zeux/pugixml/tags/v1.6 pugixml</code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="install.building"><a class="anchor" href="#install.building"></a>2.2. Building pugixml</h3>
+<div class="paragraph">
+<p>pugixml is distributed in source form without any pre-built binaries; you have to build them yourself.</p>
+</div>
+<div class="paragraph">
+<p>The complete pugixml source consists of three files - one source file, <code>pugixml.cpp</code>, and two header files, <code>pugixml.hpp</code> and <code>pugiconfig.hpp</code>. <code>pugixml.hpp</code> is the primary header which you need to include in order to use pugixml classes/functions; <code>pugiconfig.hpp</code> is a supplementary configuration file (see <a href="#install.building.config">Additional configuration options</a>). The rest of this guide assumes that <code>pugixml.hpp</code> is either in the current directory or in one of include directories of your projects, so that <code>#include "pugixml.hpp"</code> can find the header; however you can also use relative path (i.e. <code>#include "../libs/pugixml/src/pugixml.hpp"</code>) or include directory-relative path (i.e. <code>#include &lt;xml/thirdparty/pugixml/src/pugixml.hpp&gt;</code>).</p>
+</div>
+<div class="sect3">
+<h4 id="install.building.embed"><a class="anchor" href="#install.building.embed"></a>2.2.1. Building pugixml as a part of another static library/executable</h4>
+<div class="paragraph">
+<p>The easiest way to build pugixml is to compile the source file, <code>pugixml.cpp</code>, along with the existing library/executable. This process depends on the method of building your application; for example, if you&#8217;re using Microsoft Visual Studio <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>, Apple Xcode, Code::Blocks or any other IDE, just add <code>pugixml.cpp</code> to one of your projects.</p>
+</div>
+<div class="paragraph">
+<p>If you&#8217;re using Microsoft Visual Studio and the project has precompiled headers turned on, you&#8217;ll see the following error messages:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre>pugixml.cpp(3477) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The correct way to resolve this is to disable precompiled headers for <code>pugixml.cpp</code>; you have to set "Create/Use Precompiled Header" option (Properties dialog &#8594; C/C&#43;&#43; &#8594; Precompiled Headers &#8594; Create/Use Precompiled Header) to "Not Using Precompiled Headers". You&#8217;ll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option):</p>
+</div>
+<table class="tableblock frame-none grid-all spread">
+<colgroup>
+<col style="width: 25%;">
+<col style="width: 25%;">
+<col style="width: 25%;">
+<col style="width: 25%;">
+</colgroup>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2005_pch1.png"><img src="images/vs2005_pch1.png" alt="vs2005 pch1"></a>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2005_pch2.png"><img src="images/vs2005_pch2.png" alt="vs2005 pch2"></a>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2005_pch3.png"><img src="images/vs2005_pch3.png" alt="vs2005 pch3"></a>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2005_pch4.png"><img src="images/vs2005_pch4.png" alt="vs2005 pch4"></a>
+</div>
+</div></div></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect3">
+<h4 id="install.building.static"><a class="anchor" href="#install.building.static"></a>2.2.2. Building pugixml as a standalone static library</h4>
+<div class="paragraph">
+<p>It&#8217;s possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010+, and configuration scripts for CMake and premake4. You&#8217;re welcome to submit project files/build scripts for other software; see <a href="#overview.feedback">Feedback</a>.</p>
+</div>
+<div class="paragraph">
+<p>There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like <code>pugixml_vs2008.vcproj</code>, and another one for statically linked CRT, which has a name like <code>pugixml_vs2008_static.vcproj</code>. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. <code>pugixml_vs2008.vcproj</code> for Microsoft Visual Studio 2008).</p>
+</div>
+<div class="paragraph">
+<p>In addition to adding pugixml project to your workspace, you&#8217;ll have to make sure that your application links with pugixml library. If you&#8217;re using Microsoft Visual Studio 2005/2008, you can add a dependency from your application project to pugixml one. If you&#8217;re using Microsoft Visual Studio 2010+, you&#8217;ll have to add a reference to your application project instead. For other IDEs/systems, consult the relevant documentation.</p>
+</div>
+<table class="tableblock frame-none grid-all spread">
+<colgroup>
+<col style="width: 25%;">
+<col style="width: 25%;">
+<col style="width: 25%;">
+<col style="width: 25%;">
+</colgroup>
+<thead>
+<tr>
+<th class="tableblock halign-left valign-top" colspan="2">Microsoft Visual Studio 2005/2008</th>
+<th class="tableblock halign-left valign-top" colspan="2">Microsoft Visual Studio 2010+</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2005_link1.png"><img src="images/vs2005_link1.png" alt="vs2005 link1"></a>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2005_link2.png"><img src="images/vs2005_link2.png" alt="vs2005 link2"></a>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2010_link1.png"><img src="images/vs2010_link1.png" alt="vs2010 link1"></a>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/vs2010_link2.png"><img src="images/vs2010_link2.png" alt="vs2010 link2"></a>
+</div>
+</div></div></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect3">
+<h4 id="install.building.shared"><a class="anchor" href="#install.building.shared"></a>2.2.3. Building pugixml as a standalone shared library</h4>
+<div class="paragraph">
+<p>It&#8217;s possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you&#8217;ll have to do it yourself. Generally, if you&#8217;re using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you&#8217;re using MSVC-based toolchain, you&#8217;ll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining <a href="#PUGIXML_API">PUGIXML_API</a> macro, i.e. via <code>pugiconfig.hpp</code>:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-cp">#ifdef _DLL</span>
+ <span class="tok-cp">#define PUGIXML_API __declspec(dllexport)</span>
+<span class="tok-cp">#else</span>
+ <span class="tok-cp">#define PUGIXML_API __declspec(dllimport)</span>
+<span class="tok-cp">#endif</span></code></pre>
+</div>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+If you&#8217;re using STL-related functions, you should use the shared runtime library to ensure that a single heap is used for STL allocations in your application and in pugixml; in MSVC, this means selecting the 'Multithreaded DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (<code>/MD</code> or <code>/MDd</code> linker switch). You should also make sure that your runtime library choice is consistent between different projects.
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect3">
+<h4 id="install.building.header"><a class="anchor" href="#install.building.header"></a>2.2.4. Using pugixml in header-only mode</h4>
+<div id="PUGIXML_HEADER_ONLY" class="paragraph">
+<p>It&#8217;s possible to use pugixml in header-only mode. This means that all source code for pugixml will be included in every translation unit that includes <code>pugixml.hpp</code>. This is how most of Boost and STL libraries work.</p>
+</div>
+<div class="paragraph">
+<p>Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using <a href="#PUGIXML_NO_XPATH">PUGIXML_NO_XPATH</a> define to improve compilation time.</p>
+</div>
+<div class="paragraph">
+<p>To enable header-only mode, you have to define <code>PUGIXML_HEADER_ONLY</code>. You can either do it in <code>pugiconfig.hpp</code>, or provide them via compiler command-line.</p>
+</div>
+<div class="paragraph">
+<p>Note that it is safe to compile <code>pugixml.cpp</code> if <code>PUGIXML_HEADER_ONLY</code> is defined - so if you want to i.e. use header-only mode only in Release configuration, you
+can include pugixml.cpp in your project (see <a href="#install.building.embed">Building pugixml as a part of another static library/executable</a>), and conditionally enable header-only mode in <code>pugiconfig.hpp</code> like this:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-cp">#ifndef _DEBUG</span>
+ <span class="tok-cp">#define PUGIXML_HEADER_ONLY</span>
+<span class="tok-cp">#endif</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect3">
+<h4 id="install.building.config"><a class="anchor" href="#install.building.config"></a>2.2.5. Additional configuration options</h4>
+<div class="paragraph">
+<p>pugixml uses several defines to control the compilation process. There are two ways to define them: either put the needed definitions to <code>pugiconfig.hpp</code> (it has some examples that are commented out) or provide them via compiler command-line. Consistency is important: the definitions should match in all source files that include <code>pugixml.hpp</code> (including pugixml sources) throughout the application. Adding defines to <code>pugiconfig.hpp</code> lets you guarantee this, unless your macro definition is wrapped in preprocessor <code>#if</code>/<code>#ifdef</code> directive and this directive is not consistent. <code>pugiconfig.hpp</code> will never contain anything but comments, which means that when upgrading to a new version, you can safely leave your modified version intact.</p>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_WCHAR_MODE"></a><code>PUGIXML_WCHAR_MODE</code> define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use <code>char</code> as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on <code>wchar_t</code> size, most functions use <code>wchar_t</code> as character type). See <a href="#dom.unicode">Unicode interface</a> for more details.</p>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_NO_XPATH"></a><code>PUGIXML_NO_XPATH</code> define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space.</p>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_NO_STL"></a><code>PUGIXML_NO_STL</code> define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation.</p>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_NO_EXCEPTIONS"></a><code>PUGIXML_NO_EXCEPTIONS</code> define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities.</p>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_API"></a><code>PUGIXML_API</code>, <a id="PUGIXML_CLASS"></a><code>PUGIXML_CLASS</code> and <a id="PUGIXML_FUNCTION"></a><code>PUGIXML_FUNCTION</code> defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of <code>PUGIXML_CLASS</code> or <code>PUGIXML_FUNCTION</code> definitions, <code>PUGIXML_API</code> definition is used instead. For example, to specify fixed calling convention, you can define <code>PUGIXML_FUNCTION</code> to i.e. <code>__fastcall</code>. Another example is DLL import/export attributes in MSVC (see <a href="#install.building.shared">Building pugixml as a standalone shared library</a>).</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+In that example <code>PUGIXML_API</code> is inconsistent between several source files; this is an exception to the consistency rule.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_MEMORY_PAGE_SIZE"></a><code>PUGIXML_MEMORY_PAGE_SIZE</code>, <a id="PUGIXML_MEMORY_OUTPUT_STACK"></a><code>PUGIXML_MEMORY_OUTPUT_STACK</code> and <a id="PUGIXML_MEMORY_XPATH_PAGE_SIZE"></a><code>PUGIXML_MEMORY_XPATH_PAGE_SIZE</code> can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <a href="#dom.memory.tuning">Memory consumption tuning</a>.</p>
+</div>
+<div class="paragraph">
+<p><a id="PUGIXML_HAS_LONG_LONG"></a><code>PUGIXML_HAS_LONG_LONG</code> define enables support for <code>long long</code> type in pugixml. This define is automatically enabled if your platform is known to have <code>long long</code> support (i.e. has C&#43;&#43;11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports <code>long long</code> but in fact it does, you can enable the define manually.</p>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="install.portability"><a class="anchor" href="#install.portability"></a>2.3. Portability</h3>
+<div class="paragraph">
+<p>pugixml is written in standard-compliant C&#43;&#43; with some compiler-specific workarounds where appropriate. pugixml is compatible with the C&#43;&#43;11 standard, but does not require C&#43;&#43;11 support. Each version is tested with a unit test suite (with code coverage about 99%) on the following platforms:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Microsoft Windows:</p>
+<div class="ulist">
+<ul>
+<li>
+<p>Borland C&#43;&#43; Compiler 5.82</p>
+</li>
+<li>
+<p>Digital Mars C&#43;&#43; Compiler 8.51</p>
+</li>
+<li>
+<p>Intel C&#43;&#43; Compiler 8.0, 9.0 x86/x64, 10.0 x86/x64, 11.0 x86/x64</p>
+</li>
+<li>
+<p>Metrowerks CodeWarrior 8.0</p>
+</li>
+<li>
+<p>Microsoft Visual C&#43;&#43; 6.0, 7.0 (2002), 7.1 (2003), 8.0 (2005) x86/x64, 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 (2011) x86/x64/ARM, 12.0 (2013) x86/x64/ARM and some CLR versions</p>
+</li>
+<li>
+<p>MinGW (GCC) 3.4, 4.4, 4.5, 4.6 x64</p>
+</li>
+</ul>
+</div>
+</li>
+<li>
+<p>Linux (GCC 4.4.3 x86/x64, GCC 4.8.1 x64, Clang 3.2 x64)</p>
+</li>
+<li>
+<p>FreeBSD (GCC 4.2.1 x86/x64)</p>
+</li>
+<li>
+<p>Apple MacOSX (GCC 4.0.1 x86/x64/PowerPC, Clang 3.5 x64)</p>
+</li>
+<li>
+<p>Sun Solaris (sunCC x86/x64)</p>
+</li>
+<li>
+<p>Microsoft Xbox 360</p>
+</li>
+<li>
+<p>Nintendo Wii (Metrowerks CodeWarrior 4.1)</p>
+</li>
+<li>
+<p>Sony Playstation Portable (GCC 3.4.2)</p>
+</li>
+<li>
+<p>Sony Playstation 3 (GCC 4.1.1, SNC 310.1)</p>
+</li>
+<li>
+<p>Various portable platforms (Android NDK, BlackBerry NDK, Samsung bada, Windows CE)</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="dom"><a class="anchor" href="#dom"></a>3. Document object model</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from a character stream (file, string, C&#43;&#43; I/O stream), then traversed with the special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C&#43;&#43; I/O stream or custom transport).</p>
+</div>
+<div class="sect2">
+<h3 id="dom.tree"><a class="anchor" href="#dom.tree"></a>3.1. Tree structure</h3>
+<div class="paragraph">
+<p>The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C&#43;&#43; type <a href="#xml_document">xml_document</a>. Document has one or more child nodes, which correspond to C&#43;&#43; type <a href="#xml_node">xml_node</a>. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C&#43;&#43; type <a href="#xml_attribute">xml_attribute</a>, and some additional data (i.e. name).</p>
+</div>
+<div id="xml_node_type" class="paragraph">
+<p>The tree nodes can be of one of the following types (which together form the enumeration <code>xml_node_type</code>):</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Document node (<a id="node_document"></a><code>node_document</code>) - this is the root of the tree, which consists of several child nodes. This node corresponds to <a href="#xml_document">xml_document</a> class; note that <a href="#xml_document">xml_document</a> is a sub-class of <a href="#xml_node">xml_node</a>, so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation.</p>
+</li>
+<li>
+<p>Element/tag node (<a id="node_element"></a><code>node_element</code>) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;node attr="value"&gt;&lt;child/&gt;&lt;/node&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>There are two element nodes here: one has name <code>"node"</code>, single attribute <code>"attr"</code> and single child <code>"child"</code>, another has name <code>"child"</code> and does not have any attributes or child nodes.</p>
+</div>
+</li>
+<li>
+<p>Plain character data nodes (<a id="node_pcdata"></a><code>node_pcdata</code>) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that <strong>plain character data is not a part of the element node but instead has its own node</strong>; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;node&gt; text1 &lt;child/&gt; text2 &lt;/node&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here <code>"node"</code> element has three children, two of which are PCDATA nodes with values <code>" text1 "</code> and <code>" text2 "</code>.</p>
+</div>
+</li>
+<li>
+<p>Character data nodes (<a id="node_cdata"></a><code>node_cdata</code>) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;node&gt; &lt;![CDATA[[text1]]&gt; &lt;child/&gt; &lt;![CDATA[[text2]]&gt; &lt;/node&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>CDATA nodes make it easy to include non-escaped <code>&lt;</code>, <code>&amp;</code> and <code>&gt;</code> characters in plain text. CDATA value can not contain the character sequence <code>]]&gt;</code>, since it is used to determine the end of node contents.</p>
+</div>
+</li>
+<li>
+<p>Comment nodes (<a id="node_comment"></a><code>node_comment</code>) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;!-- comment text --&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here the comment node has value <code>"comment text"</code>. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_comments">parse_comments</a> flag.</p>
+</div>
+</li>
+<li>
+<p>Processing instruction node (<a id="node_pi"></a><code>node_pi</code>) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;?name value?&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here the name (also called PI target) is <code>"name"</code>, and the value is <code>"value"</code>. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_pi">parse_pi</a> flag.</p>
+</div>
+</li>
+<li>
+<p>Declaration node (<a id="node_declaration"></a><code>node_declaration</code>) represents document declarations in XML. Declaration nodes have a name (<code>"xml"</code>) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;?xml version="1.0"?&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here the node has name <code>"xml"</code> and a single attribute with name <code>"version"</code> and value <code>"1.0"</code>. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_declaration">parse_declaration</a> flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with <a href="#format_no_declaration">format_no_declaration</a> flag.</p>
+</div>
+</li>
+<li>
+<p>Document type declaration node (<a id="node_doctype"></a><code>node_doctype</code>) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like <code>&lt;!ENTITY&gt;</code>. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:</p>
+<div class="listingblock">
+<div class="content">
+<pre>&lt;!DOCTYPE greeting [ &lt;!ELEMENT greeting (#PCDATA)&gt; ]&gt;</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Here the node has value <code>"greeting [ &lt;!ELEMENT greeting (#PCDATA)&gt; ]"</code>. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <a href="#parse_doctype">parse_doctype</a> flag.</p>
+</div>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Finally, here is a complete example of XML document and the corresponding tree representation (<a href="samples/tree.xml" class="bare">samples/tree.xml</a>):</p>
+</div>
+<table class="tableblock frame-none grid-all spread">
+<colgroup>
+<col style="width: 50%;">
+<col style="width: 50%;">
+</colgroup>
+<tbody>
+<tr>
+<td class="tableblock halign-left valign-top"><div><div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="xml"><span class="tok-cp">&lt;?xml version=&quot;1.0&quot;?&gt;</span>
+<span class="tok-nt">&lt;mesh</span> <span class="tok-na">name=</span><span class="tok-s">&quot;mesh_root&quot;</span><span class="tok-nt">&gt;</span>
+ <span class="tok-c">&lt;!-- here is a mesh node --&gt;</span>
+ some text
+ <span class="tok-cp">&lt;![CDATA[someothertext]]&gt;</span>
+ some more text
+ <span class="tok-nt">&lt;node</span> <span class="tok-na">attr1=</span><span class="tok-s">&quot;value1&quot;</span> <span class="tok-na">attr2=</span><span class="tok-s">&quot;value2&quot;</span> <span class="tok-nt">/&gt;</span>
+ <span class="tok-nt">&lt;node</span> <span class="tok-na">attr1=</span><span class="tok-s">&quot;value2&quot;</span><span class="tok-nt">&gt;</span>
+ <span class="tok-nt">&lt;innernode/&gt;</span>
+ <span class="tok-nt">&lt;/node&gt;</span>
+<span class="tok-nt">&lt;/mesh&gt;</span>
+<span class="tok-cp">&lt;?include somedata?&gt;</span></code></pre>
+</div>
+</div></div></td>
+<td class="tableblock halign-left valign-top"><div><div class="imageblock">
+<div class="content">
+<a class="image" href="images/dom_tree.png"><img src="images/dom_tree.png" alt="dom tree"></a>
+</div>
+</div></div></td>
+</tr>
+</tbody>
+</table>
+</div>
+<div class="sect2">
+<h3 id="dom.cpp"><a class="anchor" href="#dom.cpp"></a>3.2. C&#43;&#43; interface</h3>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+All pugixml classes and functions are located in the <code>pugi</code> namespace; you have to either use explicit name qualification (i.e. <code>pugi::xml_node</code>), or to gain access to relevant symbols via <code>using</code> directive (i.e. <code>using pugi::xml_node;</code> or <code>using namespace pugi;</code>). The namespace will be omitted from all declarations in this documentation hereafter; all code examples will use fully qualified names.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>Despite the fact that there are several node types, there are only three C&#43;&#43; classes representing the tree (<code>xml_document</code>, <code>xml_node</code>, <code>xml_attribute</code>); some operations on <code>xml_node</code> are only valid for certain node types. The classes are described below.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_document"></a><a id="xml_document::document_element"></a>
+<code>xml_document</code> is the owner of the entire document structure; it is a non-copyable class. The interface of <code>xml_document</code> consists of loading functions (see <a href="#loading">Loading document</a>), saving functions (see <a href="#saving">Saving document</a>) and the entire interface of <code>xml_node</code>, which allows for document inspection and/or modification. Note that while <code>xml_document</code> is a sub-class of <code>xml_node</code>, <code>xml_node</code> is not a polymorphic type; the inheritance is present only to simplify usage. Alternatively you can use the <code>document_element</code> function to get the element node that&#8217;s the immediate child of the document.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_document::ctor"></a><a id="xml_document::dtor"></a><a id="xml_document::reset"></a>
+Default constructor of <code>xml_document</code> initializes the document to the tree with only a root node (document node). You can then populate it with data using either tree modification functions or loading functions; all loading functions destroy the previous tree with all occupied memory, which puts existing node/attribute handles for this document to invalid state. If you want to destroy the previous tree, you can use the <code>xml_document::reset</code> function; it destroys the tree and replaces it with either an empty one or a copy of the specified document. Destructor of <code>xml_document</code> also destroys the tree, thus the lifetime of the document object should exceed the lifetimes of any node/attribute handles that point to the tree.</p>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+While technically node/attribute handles can be alive when the tree they&#8217;re referring to is destroyed, calling any member function for these handles results in undefined behavior. Thus it is recommended to make sure that the document is destroyed only after all references to its nodes/attributes are destroyed.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p><a id="xml_node"></a><a id="xml_node::type"></a>
+<code>xml_node</code> is the handle to document node; it can point to any node in the document, including the document node itself. There is a common interface for nodes of all types; the actual <a href="#xml_node_type">node type</a> can be queried via the <code>xml_node::type()</code> method. Note that <code>xml_node</code> is only a handle to the actual node, not the node itself - you can have several <code>xml_node</code> handles pointing to the same underlying object. Destroying <code>xml_node</code> handle does not destroy the node and does not remove it from the tree. The size of <code>xml_node</code> is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return <code>xml_node</code> objects by value without additional overhead.</p>
+</div>
+<div id="node_null" class="paragraph">
+<p>There is a special value of <code>xml_node</code> type, known as null node or empty node (such nodes have type <code>node_null</code>). It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don&#8217;t do anything and return empty nodes/attributes or empty strings as their result (see documentation for specific functions for more detailed information). This is useful for chaining calls; i.e. you can get the grandparent of a node like so: <code>node.parent().parent()</code>; if a node is a null node or it does not have a parent, the first <code>parent()</code> call returns null node; the second <code>parent()</code> call then also returns null node, which makes error handling easier.</p>
+</div>
+<div id="xml_attribute" class="paragraph">
+<p><code>xml_attribute</code> is the handle to an XML attribute; it has the same semantics as <code>xml_node</code>, i.e. there can be several <code>xml_attribute</code> handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_attribute::ctor"></a><a id="xml_node::ctor"></a>
+Both <code>xml_node</code> and <code>xml_attribute</code> have the default constructor which initializes them to null objects.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_attribute::comparison"></a><a id="xml_node::comparison"></a>
+<code>xml_node</code> and <code>xml_attribute</code> try to behave like pointers, that is, they can be compared with other objects of the same type, making it possible to use them as keys in associative containers. All handles to the same underlying object are equal, and any two handles to different underlying objects are not equal. Null handles only compare as equal to themselves. The result of relational comparison can not be reliably determined from the order of nodes in file or in any other way. Do not use relational comparison operators except for search optimization (i.e. associative container keys).</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_attribute::hash_value"></a><a id="xml_node::hash_value"></a>
+If you want to use <code>xml_node</code> or <code>xml_attribute</code> objects as keys in hash-based associative containers, you can use the <code>hash_value</code> member functions. They return the hash values that are guaranteed to be the same for all handles to the same underlying object. The hash value for null handles is 0.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_attribute::unspecified_bool_type"></a><a id="xml_node::unspecified_bool_type"></a><a id="xml_attribute::empty"></a><a id="xml_node::empty"></a>
+Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node/attribute is empty with the following code: <code>if (node) { &#8230;&#8203; }</code> or <code>if (!node) { &#8230;&#8203; } else { &#8230;&#8203; }</code>. Alternatively you can check if a given <code>xml_node</code>/<code>xml_attribute</code> handle is null by calling the following methods:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">empty</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">empty</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Nodes and attributes do not exist without a document tree, so you can&#8217;t create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling <a href="#xml_node::remove_child">xml_node::remove_child</a>) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="dom.unicode"><a class="anchor" href="#dom.unicode"></a>3.3. Unicode interface</h3>
+<div class="paragraph">
+<p>There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via <a href="#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a> define; you can set it via <code>pugiconfig.hpp</code> or via preprocessor options, as discussed in <a href="#install.building.config">Additional configuration options</a>. If this define is set, the wchar_t interface is used; otherwise (by default) the char interface is used. The exact wide character encoding is assumed to be either UTF-16 or UTF-32 and is determined based on the size of <code>wchar_t</code> type.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+If the size of <code>wchar_t</code> is 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some characters are represented as two code points.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">value</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>and like this in wchar_t mode:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">value</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="char_t"></a><a id="string_t"></a>
+There is a special type, <code>pugi::char_t</code>, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type <code>pugi::string_t</code>, which is defined as the STL string of the character type; it corresponds to <code>std::string</code> in char mode and to <code>std::wstring</code> in wchar_t mode.</p>
+</div>
+<div class="paragraph">
+<p>In addition to the interface, the internal implementation changes to store XML data as <code>pugi::char_t</code>; this means that these two modes have different memory usage characteristics. The conversion to <code>pugi::char_t</code> upon document loading and from <code>pugi::char_t</code> upon document saving happen automatically, which also carries minor performance penalty. The general advice however is to select the character mode based on usage scenario, i.e. if UTF-8 is inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice.</p>
+</div>
+<div class="paragraph">
+<p><a id="as_utf8"></a><a id="as_wide"></a>
+There are cases when you&#8217;ll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <span class="tok-n">as_utf8</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">str</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span> <span class="tok-n">as_wide</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">str</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Both functions accept a null-terminated string as an argument <code>str</code>, and return the converted string. <code>as_utf8</code> performs conversion from UTF-16/32 to UTF-8; <code>as_wide</code> performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. <code>str</code> has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <span class="tok-n">as_utf8</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-o">&amp;</span> <span class="tok-n">str</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span> <span class="tok-n">as_wide</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-o">&amp;</span> <span class="tok-n">str</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+<div class="paragraph">
+<p>Most examples in this documentation assume char interface and therefore will not compile with <a href="#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a>. This is done to simplify the documentation; usually the only changes you&#8217;ll have to make is to pass <code>wchar_t</code> string literals, i.e. instead of</p>
+</div>
+<div class="paragraph">
+<p><code>xml_node node = doc.child("bookstore").find_child_by_attribute("book", "id", "12345");</code></p>
+</div>
+<div class="paragraph">
+<p>you&#8217;ll have to use</p>
+</div>
+<div class="paragraph">
+<p><code>xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");</code></p>
+</div>
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="dom.thread"><a class="anchor" href="#dom.thread"></a>3.4. Thread-safety guarantees</h3>
+<div class="paragraph">
+<p>Almost all functions in pugixml have the following thread-safety guarantees:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>it is safe to call free (non-member) functions from multiple threads</p>
+</li>
+<li>
+<p>it is safe to perform concurrent read-only accesses to the same tree (all constant member functions do not modify the tree)</p>
+</li>
+<li>
+<p>it is safe to perform concurrent read/write accesses, if there is only one read or write access to the single tree at a time</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Concurrent modification and traversing of a single tree requires synchronization, for example via reader-writer lock. Modification includes altering document structure and altering individual node/attribute data, i.e. changing names/values.</p>
+</div>
+<div class="paragraph">
+<p>The only exception is <a href="#set_memory_management_functions">set_memory_management_functions</a>; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see <a href="#dom.memory.custom">Custom memory allocation/deallocation functions</a>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="dom.exception"><a class="anchor" href="#dom.exception"></a>3.5. Exception guarantees</h3>
+<div class="paragraph">
+<p>With the exception of XPath, pugixml itself does not throw any exceptions. Additionally, most pugixml functions have a no-throw exception guarantee.</p>
+</div>
+<div class="paragraph">
+<p>This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. <a href="#xml_node::traverse">xml_node::traverse</a> or <a href="#xml_node::find_node">xml_node::find_node</a>) do not provide any exception guarantees beyond the ones provided by the callback.</p>
+</div>
+<div class="paragraph">
+<p>If exception handling is not disabled with <a href="#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a> define, XPath functions may throw <a href="#xpath_exception">xpath_exception</a> on parsing errors; also, XPath functions may throw <code>std::bad_alloc</code> in low memory conditions. Still, XPath functions provide strong exception guarantee.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="dom.memory"><a class="anchor" href="#dom.memory"></a>3.6. Memory management</h3>
+<div class="paragraph">
+<p>pugixml requests the memory needed for document storage in big chunks, and allocates document data inside those chunks. This section discusses replacing functions used for chunk allocation and internal memory management implementation.</p>
+</div>
+<div class="sect3">
+<h4 id="dom.memory.custom"><a class="anchor" href="#dom.memory.custom"></a>3.6.1. Custom memory allocation/deallocation functions</h4>
+<div class="paragraph">
+<p><a id="allocation_function"></a><a id="deallocation_function"></a>
+All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">typedef</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-p">(</span><span class="tok-o">*</span><span class="tok-n">allocation_function</span><span class="tok-p">)(</span><span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+<span class="tok-k">typedef</span> <span class="tok-nf">void</span> <span class="tok-p">(</span><span class="tok-o">*</span><span class="tok-n">deallocation_function</span><span class="tok-p">)(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">ptr</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="set_memory_management_functions"></a><a id="get_memory_allocation_function"></a><a id="get_memory_deallocation_function"></a>
+You can use the following accessor functions to change or get current memory management functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">void</span> <span class="tok-nf">set_memory_management_functions</span><span class="tok-p">(</span><span class="tok-n">allocation_function</span> <span class="tok-n">allocate</span><span class="tok-p">,</span> <span class="tok-n">deallocation_function</span> <span class="tok-n">deallocate</span><span class="tok-p">);</span>
+<span class="tok-n">allocation_function</span> <span class="tok-nf">get_memory_allocation_function</span><span class="tok-p">();</span>
+<span class="tok-n">deallocation_function</span> <span class="tok-nf">get_memory_deallocation_function</span><span class="tok-p">();</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of <code>void*</code> and <code>double</code> types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to return null pointer (throwing an exception from allocation function results in undefined behavior).</p>
+</div>
+<div class="paragraph">
+<p>Deallocation function is called with the pointer that was returned by some call to allocation function; it is never called with a null pointer. If memory management functions are not thread-safe, library thread safety is not guaranteed.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of custom memory management (<a href="samples/custom_memory_management.cpp" class="bare">samples/custom_memory_management.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-nf">custom_allocate</span><span class="tok-p">(</span><span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">return</span> <span class="tok-k">new</span> <span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">nothrow</span><span class="tok-p">)</span> <span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span>
+<span class="tok-p">}</span>
+
+<span class="tok-kt">void</span> <span class="tok-nf">custom_deallocate</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">ptr</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">delete</span><span class="tok-p">[]</span> <span class="tok-k">static_cast</span><span class="tok-o">&lt;</span><span class="tok-kt">char</span><span class="tok-o">*&gt;</span><span class="tok-p">(</span><span class="tok-n">ptr</span><span class="tok-p">);</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">set_memory_management_functions</span><span class="tok-p">(</span><span class="tok-n">custom_allocate</span><span class="tok-p">,</span> <span class="tok-n">custom_deallocate</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.</p>
+</div>
+</div>
+<div class="sect3">
+<h4 id="dom.memory.tuning"><a class="anchor" href="#dom.memory.tuning"></a>3.6.2. Memory consumption tuning</h4>
+<div class="paragraph">
+<p>There are several important buffering optimizations in pugixml that rely on predefined constants. These constants have default values that were tuned for common usage patterns; for some applications, changing these constants might improve memory consumption or increase performance. Changing these constants is not recommended unless their default values result in visible problems.</p>
+</div>
+<div class="paragraph">
+<p>These constants can be tuned via configuration defines, as discussed in <a href="#install.building.config">Additional configuration options</a>; it is recommended to set them in <code>pugiconfig.hpp</code>.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><code>PUGIXML_MEMORY_PAGE_SIZE</code> controls the page size for document memory allocation. Memory for node/attribute objects is allocated in pages of the specified size. The default size is 32 Kb; for some applications the size is too large (i.e. embedded systems with little heap space or applications that keep lots of XML documents in memory). A minimum size of 1 Kb is recommended.</p>
+</li>
+<li>
+<p><code>PUGIXML_MEMORY_OUTPUT_STACK</code> controls the cumulative stack space required to output the node. Any output operation (i.e. saving a subtree to file) uses an internal buffering scheme for performance reasons. The default size is 10 Kb; if you&#8217;re using node output from threads with little stack space, decreasing this value can prevent stack overflows. A minimum size of 1 Kb is recommended.</p>
+</li>
+<li>
+<p><code>PUGIXML_MEMORY_XPATH_PAGE_SIZE</code> controls the page size for XPath memory allocation. Memory for XPath query objects as well as internal memory for XPath evaluation is allocated in pages of the specified size. The default size is 4 Kb; if you have a lot of resident XPath query objects, you might need to decrease the size to improve memory consumption. A minimum size of 256 bytes is recommended.</p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect3">
+<h4 id="dom.memory.internals"><a class="anchor" href="#dom.memory.internals"></a>3.6.3. Document memory management internals</h4>
+<div class="paragraph">
+<p>Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the <a href="#xml_document">xml_document</a> object.</p>
+</div>
+<div class="paragraph">
+<p>When the document is loaded from file/buffer, unless an inplace loading function is used (see <a href="#loading.memory">Loading document from memory</a>), a complete copy of character stream is made; all names/values of nodes and attributes are allocated in this buffer. This buffer is allocated via a single large allocation and is only freed when document memory is reclaimed (i.e. if the <a href="#xml_document">xml_document</a> object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns.</p>
+</div>
+<div class="paragraph">
+<p>All additional memory, such as memory for document structure (node/attribute objects) and memory for node/attribute names/values is allocated in pages on the order of 32 Kb; actual objects are allocated inside the pages using a memory management scheme optimized for fast allocation/deallocation of many small objects. Because of the scheme specifics, the pages are only destroyed if all objects inside them are destroyed; also, generally destroying an object does not mean that subsequent object creation will reuse the same memory. This means that it is possible to devise a usage scheme which will lead to higher memory usage than expected; one example is adding a lot of nodes, and them removing all even numbered ones; not a single page is reclaimed in the process. However this is an example specifically crafted to produce unsatisfying behavior; in all practical usage scenarios the memory consumption is less than that of a general-purpose allocator because allocation meta-data is very small in size.</p>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="loading"><a class="anchor" href="#loading"></a>4. Loading document</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>pugixml provides several functions for loading XML data from various places - files, C&#43;&#43; iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed for performance reasons. Also some XML transformations (i.e. EOL handling or attribute value normalization) can impact parsing speed and thus can be disabled. However for vast majority of XML documents there is no performance difference between different parsing options. Parsing options also control whether certain XML nodes are parsed; see <a href="#loading.options">Parsing options</a> for more information.</p>
+</div>
+<div class="paragraph">
+<p>XML data is always converted to internal character format (see <a href="#dom.unicode">Unicode interface</a>) before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it&#8217;s a strict subset of UTF-16) and handles all encoding conversions automatically. Unless explicit encoding is specified, loading functions perform automatic encoding detection based on first few characters of XML data, so in almost all cases you do not have to specify document encoding. Encoding conversion is described in more detail in <a href="#loading.encoding">Encodings</a>.</p>
+</div>
+<div class="sect2">
+<h3 id="loading.file"><a class="anchor" href="#loading.file"></a>4.1. Loading document from file</h3>
+<div class="paragraph">
+<p><a id="xml_document::load_file"></a><a id="xml_document::load_file_wide"></a>
+The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <a href="#loading.options">Parsing options</a>) and input data encoding (see <a href="#loading.encoding">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.</p>
+</div>
+<div class="paragraph">
+<p>File path is passed to the system file opening function as is in case of the first function (which accepts <code>const char* path</code>); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.</p>
+</div>
+<div class="paragraph">
+<p><code>load_file</code> destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an <a href="#xml_parse_result">xml_parse_result</a> object; this object contains the operation status and the related information (i.e. last successfully parsed position in the input file, if parsing fails). See <a href="#loading.errors">Handling parsing errors</a> for error handling details.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of loading XML document from file (<a href="samples/load_file.cpp" class="bare">samples/load_file.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-s">&quot;tree.xml&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Load result: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, mesh name: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;mesh&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="loading.memory"><a class="anchor" href="#loading.memory"></a>4.2. Loading document from memory</h3>
+<div class="paragraph">
+<p><a id="xml_document::load_buffer"></a><a id="xml_document::load_buffer_inplace"></a><a id="xml_document::load_buffer_inplace_own"></a>
+Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from GZip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load_buffer_inplace_own</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>All functions accept the buffer which is represented by a pointer to XML data, <code>contents</code>, and data size in bytes. Also there are two optional arguments, which specify parsing options (see <a href="#loading.options">Parsing options</a>) and input data encoding (see <a href="#loading.encoding">Encodings</a>). The buffer does not have to be zero-terminated.</p>
+</div>
+<div class="paragraph">
+<p><code>load_buffer</code> function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - <code>load_buffer_inplace</code> and <code>load_buffer_inplace_own</code> store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer&#8217;s lifetime exceeds that of the tree if you&#8217;re using inplace functions. In addition to that, <code>load_buffer_inplace</code> does not assume ownership of the buffer, so you&#8217;ll have to destroy it yourself; <code>load_buffer_inplace_own</code> assumes ownership of the buffer and destroys it once it is not needed. This means that if you&#8217;re using <code>load_buffer_inplace_own</code>, you have to allocate memory with pugixml allocation function (you can get it via <a href="#get_memory_allocation_function">get_memory_allocation_function</a>).</p>
+</div>
+<div class="paragraph">
+<p>The best way from the performance/memory point of view is to load document using <code>load_buffer_inplace_own</code>; this function has maximum control of the buffer with XML data so it is able to avoid redundant copies and reduce peak memory usage while parsing. This is the recommended function if you have to load the document from memory and performance is critical.</p>
+</div>
+<div id="xml_document::load_string" class="paragraph">
+<p>There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>It is equivalent to calling <code>load_buffer</code> with <code>size</code> being either <code>strlen(contents)</code> or <code>wcslen(contents) * sizeof(wchar_t)</code>, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of loading XML document from memory using different functions (<a href="samples/load_memory.cpp" class="bare">samples/load_memory.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char</span> <span class="tok-n">source</span><span class="tok-p">[]</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&lt;mesh name=&#39;sphere&#39;&gt;&lt;bounds&gt;0 0 1 1&lt;/bounds&gt;&lt;/mesh&gt;&quot;</span><span class="tok-p">;</span>
+<span class="tok-kt">size_t</span> <span class="tok-n">size</span> <span class="tok-o">=</span> <span class="tok-k">sizeof</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// You can use load_buffer to load document from immutable memory block:</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// You can use load_buffer_inplace to load document from mutable memory block; the block&#39;s lifetime must exceed that of document</span>
+<span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">buffer</span> <span class="tok-o">=</span> <span class="tok-k">new</span> <span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span>
+<span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// The block can be allocated by any method; the block is modified during parsing</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// You have to destroy the block yourself after the document is no longer used</span>
+<span class="tok-k">delete</span><span class="tok-p">[]</span> <span class="tok-n">buffer</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block</span>
+<span class="tok-c1">// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect</span>
+<span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">buffer</span> <span class="tok-o">=</span> <span class="tok-k">static_cast</span><span class="tok-o">&lt;</span><span class="tok-kt">char</span><span class="tok-o">*&gt;</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">get_memory_allocation_function</span><span class="tok-p">()(</span><span class="tok-n">size</span><span class="tok-p">));</span>
+<span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// The block will be deleted by the document</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace_own</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// You can use load to load document from null-terminated strings, for example literals:</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">&quot;&lt;mesh name=&#39;sphere&#39;&gt;&lt;bounds&gt;0 0 1 1&lt;/bounds&gt;&lt;/mesh&gt;&quot;</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="loading.stream"><a class="anchor" href="#loading.stream"></a>4.3. Loading document from C&#43;&#43; IOstreams</h3>
+<div id="xml_document::load_stream" class="paragraph">
+<p>To enhance interoperability, pugixml provides functions for loading document from any object which implements C&#43;&#43; <code>std::istream</code> interface. This allows you to load documents from any standard C&#43;&#43; stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">istream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">load</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wistream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>load</code> with <code>std::istream</code> argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling <code>xml_document::load</code> on an opened <code>std::ifstream</code> object is equivalent to calling <code>xml_document::load_file</code>.</p>
+</div>
+<div class="paragraph">
+<p><code>load</code> with <code>std::wstream</code> argument treats the stream contents as a wide character stream (encoding is always <a href="#encoding_wchar">encoding_wchar</a>). Because of this, using <code>load</code> with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the <code>imbue</code> function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of loading XML document from file using streams (<a href="samples/load_stream.cpp" class="bare">samples/load_stream.cpp</a>); read the sample code for more complex examples involving wide streams and locales:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ifstream</span> <span class="tok-n">stream</span><span class="tok-p">(</span><span class="tok-s">&quot;weekly-utf-8.xml&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load</span><span class="tok-p">(</span><span class="tok-n">stream</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="loading.errors"><a class="anchor" href="#loading.errors"></a>4.4. Handling parsing errors</h3>
+<div id="xml_parse_result" class="paragraph">
+<p>All document loading functions return the parsing result via <code>xml_parse_result</code> object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">struct</span> <span class="tok-n">xml_parse_result</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">xml_parse_status</span> <span class="tok-n">status</span><span class="tok-p">;</span>
+ <span class="tok-kt">ptrdiff_t</span> <span class="tok-n">offset</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span><span class="tok-p">;</span>
+
+ <span class="tok-k">operator</span> <span class="tok-kt">bool</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">description</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="xml_parse_status"></a><a id="xml_parse_result::status"></a>
+Parsing status is represented as the <code>xml_parse_status</code> enumeration and can be one of the following:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="status_ok"></a><code>status_ok</code> means that no error was encountered during parsing; the source stream represents the valid XML document which was fully parsed and converted to a tree.</p>
+</li>
+<li>
+<p><a id="status_file_not_found"></a><code>status_file_not_found</code> is only returned by <code>load_file</code> function and means that file could not be opened.</p>
+</li>
+<li>
+<p><a id="status_io_error"></a><code>status_io_error</code> is returned by <code>load_file</code> function and by <code>load</code> functions with <code>std::istream</code>/<code>std::wstream</code> arguments; it means that some I/O error has occurred during reading the file/stream.</p>
+</li>
+<li>
+<p><a id="status_out_of_memory"></a><code>status_out_of_memory</code> means that there was not enough memory during some allocation; any allocation failure during parsing results in this error.</p>
+</li>
+<li>
+<p><a id="status_internal_error"></a><code>status_internal_error</code> means that something went horribly wrong; currently this error does not occur</p>
+</li>
+<li>
+<p><a id="status_unrecognized_tag"></a><code>status_unrecognized_tag</code> means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as <code>#</code>.</p>
+</li>
+<li>
+<p><a id="status_bad_pi"></a><code>status_bad_pi</code> means that parsing stopped due to incorrect document declaration/processing instruction</p>
+</li>
+<li>
+<p><a id="status_bad_comment"></a><code>status_bad_comment</code>, <a id="status_bad_cdata"></a><code>status_bad_cdata</code>, <a id="status_bad_doctype"></a><code>status_bad_doctype</code> and <a id="status_bad_pcdata"></a><code>status_bad_pcdata</code> mean that parsing stopped due to the invalid construct of the respective type</p>
+</li>
+<li>
+<p><a id="status_bad_start_element"></a><code>status_bad_start_element</code> means that parsing stopped because starting tag either had no closing <code>&gt;</code> symbol or contained some incorrect symbol</p>
+</li>
+<li>
+<p><a id="status_bad_attribute"></a><code>status_bad_attribute</code> means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that <code>&lt;node attr=1&gt;</code> is incorrect in XML)</p>
+</li>
+<li>
+<p><a id="status_bad_end_element"></a><code>status_bad_end_element</code> means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and <code>&gt;</code>)</p>
+</li>
+<li>
+<p><a id="status_end_element_mismatch"></a><code>status_end_element_mismatch</code> means that parsing stopped because the closing tag did not match the opening one (i.e. <code>&lt;node&gt;&lt;/nedo&gt;</code>) or because some tag was not closed at all</p>
+</li>
+<li>
+<p><a id="status_no_document_element"></a><code>status_no_document_element</code> means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document</p>
+</li>
+</ul>
+</div>
+<div id="xml_parse_result::description" class="paragraph">
+<p><code>description()</code> member function can be used to convert parsing status to a string; the returned message is always in English, so you&#8217;ll have to write your own function if you need a localized string. However please note that the exact messages returned by <code>description()</code> function may change from version to version, so any complex status handling should be based on <code>status</code> value. Note that <code>description()</code> returns a <code>char</code> string even in <code>PUGIXML_WCHAR_MODE</code>; you&#8217;ll have to call <a href="#as_wide">as_wide</a> to get the <code>wchar_t</code> string.</p>
+</div>
+<div class="paragraph">
+<p>If parsing failed because the source data was not a valid XML, the resulting tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that was successfully parsed. Obviously, the last element may have an unexpected name/value; for example, if the attribute value does not end with the necessary quotation mark, like in <code>&lt;node attr="value&gt;some data&lt;/node&gt;</code> example, the value of attribute <code>attr</code> will contain the string <code>value&gt;some data&lt;/node&gt;</code>.</p>
+</div>
+<div id="xml_parse_result::offset" class="paragraph">
+<p>In addition to the status code, parsing result has an <code>offset</code> member, which contains the offset of last successfully parsed character if parsing failed because of an error in source data; otherwise <code>offset</code> is 0. For parsing efficiency reasons, pugixml does not track the current line during parsing; this offset is in units of <a href="#char_t">pugi::char_t</a> (bytes for character mode, wide characters for wide character mode). Many text editors support 'Go To Position' feature - you can use it to locate the exact error position. Alternatively, if you&#8217;re loading the document from memory, you can display the error chunk along with the error description (see the example code below).</p>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+Offset is calculated in the XML buffer in native encoding; if encoding conversion is performed during parsing, offset can not be used to reliably track the error position.
+</td>
+</tr>
+</table>
+</div>
+<div id="xml_parse_result::encoding" class="paragraph">
+<p>Parsing result also has an <code>encoding</code> member, which can be used to check that the source data encoding was correctly guessed. It is equal to the exact encoding used during parsing (i.e. with the exact endianness); see <a href="#loading.encoding">Encodings</a> for more information.</p>
+</div>
+<div id="xml_parse_result::bool" class="paragraph">
+<p>Parsing result object can be implicitly converted to <code>bool</code>; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a <code>bool</code>: <code>if (doc.load_file("file.xml")) { &#8230;&#8203; } else { &#8230;&#8203; }</code>.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of handling loading errors (<a href="samples/load_error_handling.cpp" class="bare">samples/load_error_handling.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span>
+
+<span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-n">result</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;XML [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">source</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;] parsed without errors, attr value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;attr&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+<span class="tok-k">else</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;XML [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">source</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;] parsed with errors, attr value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;attr&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Error description: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Error offset: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; (error at [...&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-p">(</span><span class="tok-n">source</span> <span class="tok-o">+</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="loading.options"><a class="anchor" href="#loading.options"></a>4.5. Parsing options</h3>
+<div class="paragraph">
+<p>All document loading functions accept the optional parameter <code>options</code>. This is a bitmask that customizes the parsing process: you can select the node types that are parsed and various transformations that are performed with the XML text. Disabling certain transformations can improve parsing performance for some documents; however, the code for all transformations is very well optimized, and thus the majority of documents won&#8217;t get any performance benefit. As a rule of thumb, only modify parsing flags if you want to get some nodes in the document that are excluded by default (i.e. declaration or comment nodes).</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use <code>mask | flag</code>; to disable a flag, use <code>mask &amp; ~flag</code>.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>These flags control the resulting tree contents:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="parse_declaration"></a><code>parse_declaration</code> determines if XML document declaration (node with type <a href="#node_declaration">node_declaration</a>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_doctype"></a><code>parse_doctype</code> determines if XML document type declaration (node with type <a href="#node_doctype">node_doctype</a>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_pi"></a><code>parse_pi</code> determines if processing instructions (nodes with type <a href="#node_pi">node_pi</a>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. Note that <code>&lt;?xml &#8230;&#8203;?&gt;</code> (document declaration) is not considered to be a PI. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_comments"></a><code>parse_comments</code> determines if comments (nodes with type <a href="#node_comment">node_comment</a>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_cdata"></a><code>parse_cdata</code> determines if CDATA sections (nodes with type <a href="#node_cdata">node_cdata</a>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is <strong>on</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_trim_pcdata"></a><code>parse_trim_pcdata</code> determines if leading and trailing whitespace characters are to be removed from PCDATA nodes. While for some applications leading/trailing whitespace is significant, often the application only cares about the non-whitespace contents so it&#8217;s easier to trim whitespace from text during parsing. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_ws_pcdata"></a><code>parse_ws_pcdata</code> determines if PCDATA nodes (nodes with type <a href="#node_pcdata">node_pcdata</a>) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string <code>&lt;node&gt; &lt;a/&gt; &lt;/node&gt;</code>, <code>&lt;node&gt;</code> element will have three children when <code>parse_ws_pcdata</code> is set (child with type <a href="#node_pcdata">node_pcdata</a> and value <code>" "</code>, child with type <a href="#node_element">node_element</a> and name <code>"a"</code>, and another child with type <a href="#node_pcdata">node_pcdata</a> and value <code>" "</code>), and only one child when <code>parse_ws_pcdata</code> is not set. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_ws_pcdata_single"></a><code>parse_ws_pcdata_single</code> determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. <code>&lt;node&gt; &lt;/node&gt;</code>, but is not interested in whitespace markup elsewhere. It is possible to use <a href="#parse_ws_pcdata">parse_ws_pcdata</a> flag in this case, but it results in excessive allocations and complicates document processing; this flag can be used to avoid that. As an example, after parsing XML string <code>&lt;node&gt; &lt;a&gt; &lt;/a&gt; &lt;/node&gt;</code> with <code>parse_ws_pcdata_single</code> flag set, <code>&lt;node&gt;</code> element will have one child <code>&lt;a&gt;</code>, and <code>&lt;a&gt;</code> element will have one child with type <a href="#node_pcdata">node_pcdata</a> and value <code>" "</code>. This flag has no effect if <a href="#parse_ws_pcdata">parse_ws_pcdata</a> is enabled. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_fragment"></a><code>parse_fragment</code> determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid. This flag is <strong>off</strong> by default.</p>
+</li>
+</ul>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+Using in-place parsing (<a href="#xml_document::load_buffer_inplace">load_buffer_inplace</a>) with <code>parse_fragment</code> flag may result in the loss of the last character of the buffer if it is a part of PCDATA. Since PCDATA values are null-terminated strings, the only way to resolve this is to provide a null-terminated buffer as an input to <code>load_buffer_inplace</code> - i.e. <code>doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment)</code>.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>These flags control the transformation of tree element contents:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="parse_escapes"></a><code>parse_escapes</code> determines if character and entity references are to be expanded during the parsing process. Character references have the form <code>&amp;#&#8230;&#8203;;</code> or <code>&amp;#x&#8230;&#8203;;</code> (<code>&#8230;&#8203;</code> is Unicode numeric representation of character in either decimal (<code>&amp;#&#8230;&#8203;;</code>) or hexadecimal (<code>&amp;#x&#8230;&#8203;;</code>) form), entity references are <code>&amp;lt;</code>, <code>&amp;gt;</code>, <code>&amp;amp;</code>, <code>&amp;apos;</code> and <code>&amp;quot;</code> (note that as pugixml does not handle DTD, the only allowed entities are predefined ones). If character/entity reference can not be expanded, it is left as is, so you can do additional processing later. Reference expansion is performed on attribute values and PCDATA content. This flag is <strong>on</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_eol"></a><code>parse_eol</code> determines if EOL handling (that is, replacing sequences <code>\r\n</code> by a single <code>\n</code> character, and replacing all standalone <code>\r</code> characters by <code>\n</code>) is to be performed on input data (that is, comment contents, PCDATA/CDATA contents and attribute values). This flag is <strong>on</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_wconv_attribute"></a><code>parse_wconv_attribute</code> determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (<code>' '</code>). New line characters are always treated as if <a href="#parse_eol">parse_eol</a> is set, i.e. <code>\r\n</code> is converted to a single space. This flag is <strong>on</strong> by default.</p>
+</li>
+<li>
+<p><a id="parse_wnorm_attribute"></a><code>parse_wnorm_attribute</code> determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if <a href="#parse_wconv_attribute">parse_wconv_attribute</a> was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. <a href="#parse_wconv_attribute">parse_wconv_attribute</a> has no effect if this flag is on. This flag is <strong>off</strong> by default.</p>
+</li>
+</ul>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+<code>parse_wconv_attribute</code> option performs transformations that are required by W3C specification for attributes that are declared as CDATA; <a href="#parse_wnorm_attribute">parse_wnorm_attribute</a> performs transformations required for NMTOKENS attributes. In the absence of document type declaration all attributes should behave as if they are declared as CDATA, thus <a href="#parse_wconv_attribute">parse_wconv_attribute</a> is the default option.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>Additionally there are three predefined option masks:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="parse_minimal"></a><code>parse_minimal</code> has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice <a href="#parse_default">parse_default</a> is usually equally fast.</p>
+</li>
+<li>
+<p><a id="parse_default"></a><code>parse_default</code> is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons.</p>
+</li>
+<li>
+<p><a id="parse_full"></a><code>parse_full</code> is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This is an example of using different parsing options (<a href="samples/load_options.cpp" class="bare">samples/load_options.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">source</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&lt;!--comment--&gt;&lt;node&gt;&amp;lt;&lt;/node&gt;&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Parsing with default options; note that comment node is not added to the tree, and entity reference &amp;lt; is expanded</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;First node value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">().</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;], node child value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Parsing with additional parse_comments option; comment node is now added to the tree</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span> <span class="tok-o">|</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_comments</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;First node value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">().</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;], node child value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Parsing with additional parse_comments option and without the (default) parse_escapes option; &amp;lt; is not expanded</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span> <span class="tok-o">|</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_comments</span><span class="tok-p">)</span> <span class="tok-o">&amp;</span> <span class="tok-o">~</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_escapes</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;First node value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">().</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;], node child value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Parsing with minimal option mask; comment node is not added to the tree, and &amp;lt; is not expanded</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_minimal</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;First node value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">().</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;], node child value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="loading.encoding"><a class="anchor" href="#loading.encoding"></a>4.6. Encodings</h3>
+<div id="xml_encoding" class="paragraph">
+<p>pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it&#8217;s a strict subset of UTF-16) and handles all encoding conversions. Most loading functions accept the optional parameter <code>encoding</code>. This is a value of enumeration type <code>xml_encoding</code>, that can have the following values:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="encoding_auto"></a><code>encoding_auto</code> means that pugixml will try to guess the encoding based on source XML data. The algorithm is a modified version of the one presented in <a href="http://www.w3.org/TR/REC-xml/#sec-guessing-no-ext-info">Appendix F.1 of XML recommendation</a>; it tries to match the first few bytes of input data with the following patterns in strict order:</p>
+<div class="ulist">
+<ul>
+<li>
+<p>If first four bytes match UTF-32 BOM (Byte Order Mark), encoding is assumed to be UTF-32 with the endianness equal to that of BOM;</p>
+</li>
+<li>
+<p>If first two bytes match UTF-16 BOM, encoding is assumed to be UTF-16 with the endianness equal to that of BOM;</p>
+</li>
+<li>
+<p>If first three bytes match UTF-8 BOM, encoding is assumed to be UTF-8;</p>
+</li>
+<li>
+<p>If first four bytes match UTF-32 representation of <code>&lt;</code>, encoding is assumed to be UTF-32 with the corresponding endianness;</p>
+</li>
+<li>
+<p>If first four bytes match UTF-16 representation of <code>&lt;?</code>, encoding is assumed to be UTF-16 with the corresponding endianness;</p>
+</li>
+<li>
+<p>If first two bytes match UTF-16 representation of <code>&lt;</code>, encoding is assumed to be UTF-16 with the corresponding endianness (this guess may yield incorrect result, but it&#8217;s better than UTF-8);</p>
+</li>
+<li>
+<p>Otherwise encoding is assumed to be UTF-8.</p>
+</li>
+</ul>
+</div>
+</li>
+<li>
+<p><a id="encoding_utf8"></a><code>encoding_utf8</code> corresponds to UTF-8 encoding as defined in the Unicode standard; UTF-8 sequences with length equal to 5 or 6 are not standard and are rejected.</p>
+</li>
+<li>
+<p><a id="encoding_utf16_le"></a><code>encoding_utf16_le</code> corresponds to little-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.</p>
+</li>
+<li>
+<p><a id="encoding_utf16_be"></a><code>encoding_utf16_be</code> corresponds to big-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.</p>
+</li>
+<li>
+<p><a id="encoding_utf16"></a><code>encoding_utf16</code> corresponds to UTF-16 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.</p>
+</li>
+<li>
+<p><a id="encoding_utf32_le"></a><code>encoding_utf32_le</code> corresponds to little-endian UTF-32 encoding as defined in the Unicode standard.</p>
+</li>
+<li>
+<p><a id="encoding_utf32_be"></a><code>encoding_utf32_be</code> corresponds to big-endian UTF-32 encoding as defined in the Unicode standard.</p>
+</li>
+<li>
+<p><a id="encoding_utf32"></a><code>encoding_utf32</code> corresponds to UTF-32 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.</p>
+</li>
+<li>
+<p><a id="encoding_wchar"></a><code>encoding_wchar</code> corresponds to the encoding of <code>wchar_t</code> type; it has the same meaning as either <code>encoding_utf16</code> or <code>encoding_utf32</code>, depending on <code>wchar_t</code> size.</p>
+</li>
+<li>
+<p><a id="encoding_latin1"></a><code>encoding_latin1</code> corresponds to ISO-8859-1 encoding (also known as Latin-1).</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>The algorithm used for <code>encoding_auto</code> correctly detects any supported Unicode encoding for all well-formed XML documents (since they start with document declaration) and for all other XML documents that start with <code>&lt;</code>; if your XML document does not start with <code>&lt;</code> and has encoding that is different from UTF-8, use the specific encoding.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; moreover, in case no encoding conversion is performed, the invalid sequences are not removed, so you&#8217;ll get them as is in node/attribute contents.
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="loading.w3c"><a class="anchor" href="#loading.w3c"></a>4.7. Conformance to W3C specification</h3>
+<div class="paragraph">
+<p>pugixml is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons.</p>
+</div>
+<div class="paragraph">
+<p>There is only one non-conformant behavior when dealing with valid XML documents: pugixml does not use information supplied in document type declaration for parsing. This means that entities declared in DOCTYPE are not expanded, and all attribute/PCDATA values are always processed in a uniform way that depends only on parsing options.</p>
+</div>
+<div class="paragraph">
+<p>As for rejecting invalid XML documents, there are a number of incompatibilities with W3C specification, including:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Multiple attributes of the same node can have equal names.</p>
+</li>
+<li>
+<p>All non-ASCII characters are treated in the same way as symbols of English alphabet, so some invalid tag names are not rejected.</p>
+</li>
+<li>
+<p>Attribute values which contain <code>&lt;</code> are not rejected.</p>
+</li>
+<li>
+<p>Invalid entity/character references are not rejected and are instead left as is.</p>
+</li>
+<li>
+<p>Comment values can contain <code>--</code>.</p>
+</li>
+<li>
+<p>XML data is not required to begin with document declaration; additionally, document declaration can appear after comments and other nodes.</p>
+</li>
+<li>
+<p>Invalid document type declarations are silently ignored in some cases.</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="access"><a class="anchor" href="#access"></a>5. Accessing document data</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>pugixml features an extensive interface for getting various types of data from the document and for traversing the document. This section provides documentation for all such functions that do not modify the tree except for XPath-related functions; see <a href="#xpath">XPath</a> for XPath reference. As discussed in <a href="#dom.cpp">C&#43;&#43; interface</a>, there are two types of handles to tree data - <a href="#xml_node">xml_node</a> and <a href="#xml_attribute">xml_attribute</a>. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see <a href="#node_null">this description</a> for details. The documentation in this section will explicitly state the results of all function in case of null inputs.</p>
+</div>
+<div class="sect2">
+<h3 id="access.basic"><a class="anchor" href="#access.basic"></a>5.1. Basic traversal functions</h3>
+<div class="paragraph">
+<p><a id="xml_node::parent"></a><a id="xml_node::first_child"></a><a id="xml_node::last_child"></a><a id="xml_node::next_sibling"></a><a id="xml_node::previous_sibling"></a><a id="xml_node::first_attribute"></a><a id="xml_node::last_attribute"></a><a id="xml_attribute::next_attribute"></a><a id="xml_attribute::previous_attribute"></a>
+The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">parent</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">first_child</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">last_child</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">next_sibling</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">previous_sibling</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">first_attribute</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">last_attribute</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">next_attribute</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">previous_attribute</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>parent</code> function returns the node&#8217;s parent; all non-null nodes except the document have non-null parent. <code>first_child</code> and <code>last_child</code> return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. <code>next_sibling</code> and <code>previous_sibling</code> return the node that&#8217;s immediately to the right/left of this node in the children list, respectively - for example, in <code>&lt;a/&gt;&lt;b/&gt;&lt;c/&gt;</code>, calling <code>next_sibling</code> for a handle that points to <code>&lt;b/&gt;</code> results in a handle pointing to <code>&lt;c/&gt;</code>, and calling <code>previous_sibling</code> results in handle pointing to <code>&lt;a/&gt;</code>. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. <code>first_attribute</code>, <code>last_attribute</code>, <code>next_attribute</code> and <code>previous_attribute</code> functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+Because of memory consumption reasons, attributes do not have a link to their parent nodes. Thus there is no <code>xml_attribute::parent()</code> function.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>Calling any of the functions above on the null handle results in a null handle - i.e. <code>node.first_child().next_sibling()</code> returns the second child of <code>node</code>, and null handle if <code>node</code> is null, has no children at all or if it has only one child node.</p>
+</div>
+<div class="paragraph">
+<p>With these functions, you can iterate through all child nodes and display all attributes like this (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-n">attr</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">first_attribute</span><span class="tok-p">();</span> <span class="tok-n">attr</span><span class="tok-p">;</span> <span class="tok-n">attr</span> <span class="tok-o">=</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">next_attribute</span><span class="tok-p">())</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.nodedata"><a class="anchor" href="#access.nodedata"></a>5.2. Getting node data</h3>
+<div class="paragraph">
+<p><a id="xml_node::name"></a><a id="xml_node::value"></a>
+Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <a href="#node_document">node_document</a> nodes do not have a name or value, <a href="#node_element">node_element</a> and <a href="#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a href="#node_pcdata">node_pcdata</a>, <a href="#node_cdata">node_cdata</a>, <a href="#node_comment">node_comment</a> and <a href="#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a href="#node_pi">node_pi</a> nodes always have a name and a value (again, value may be empty). In order to get node&#8217;s name or value, you can use the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers.</p>
+</div>
+<div id="xml_node::child_value" class="paragraph">
+<p>It is common to store data as text contents of some node - i.e. <code>&lt;node&gt;&lt;description&gt;This is a node&lt;/description&gt;&lt;/node&gt;</code>. In this case, <code>&lt;description&gt;</code> node does not have a value, but instead has a child of type <a href="#node_pcdata">node_pcdata</a> with value <code>"This is a node"</code>. pugixml provides several helper functions to parse such data:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">child_value</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_text</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">text</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>child_value()</code> returns the value of the first child with type <a href="#node_pcdata">node_pcdata</a> or <a href="#node_cdata">node_cdata</a>; <code>child_value(name)</code> is a simple wrapper for <code>child(name).child_value()</code>. For the above example, calling <code>node.child_value("description")</code> and <code>description.child_value()</code> will both produce string <code>"This is a node"</code>. If there is no child with relevant type, or if the handle is null, <code>child_value</code> functions return empty string.</p>
+</div>
+<div class="paragraph">
+<p><code>text()</code> returns a special object that can be used for working with PCDATA contents in more complex cases than just retrieving the value; it is described in <a href="#access.text">Working with text contents</a> sections.</p>
+</div>
+<div class="paragraph">
+<p>There is an example of using some of these functions <a href="#code_traverse_base_data">at the end of the next section</a>.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.attrdata"><a class="anchor" href="#access.attrdata"></a>5.3. Getting attribute data</h3>
+<div class="paragraph">
+<p><a id="xml_attribute::name"></a><a id="xml_attribute::value"></a>
+All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for <code>xml_node</code>:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In case the attribute handle is null, both functions return empty strings - they never return null pointers.</p>
+</div>
+<div id="xml_attribute::as_string" class="paragraph">
+<p>If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to <code>"sorted"</code> instead of <code>""</code>), you can use <code>as_string</code> accessor:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_string</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>It returns <code>def</code> argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to <code>value()</code>.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_attribute::as_int"></a><a id="xml_attribute::as_uint"></a><a id="xml_attribute::as_double"></a><a id="xml_attribute::as_float"></a><a id="xml_attribute::as_bool"></a><a id="xml_attribute::as_llong"></a><a id="xml_attribute::as_ullong"></a>
+In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">int</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_int</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_uint</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">double</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_double</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">float</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_float</span><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_bool</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-nb">false</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_llong</span><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">as_ullong</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>as_int</code>, <code>as_uint</code>, <code>as_llong</code>, <code>as_ullong</code>, <code>as_double</code> and <code>as_float</code> convert attribute values to numbers. If attribute handle is null or attribute value is empty, <code>def</code> argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to <code>as_int</code>, <code>as_uint</code>, <code>as_llong</code> and <code>as_ullong</code>; hexadecimal format is used if the number has <code>0x</code> or <code>0X</code> prefix) or as a floating point number in either decimal or scientific form (<code>as_double</code> or <code>as_float</code>). Any extra characters are silently discarded, i.e. <code>as_int</code> will return <code>1</code> for string <code>"1abc"</code>.</p>
+</div>
+<div class="paragraph">
+<p>In case the input string contains a number that is out of the target numeric range, the result is undefined.</p>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+Number conversion functions depend on current C locale as set with <code>setlocale</code>, so may return unexpected results if the locale is different from <code>"C"</code>.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p><code>as_bool</code> converts attribute value to boolean as follows: if attribute handle is null, <code>def</code> argument is returned (which is <code>false</code> by default). If attribute value is empty, <code>false</code> is returned. Otherwise, <code>true</code> is returned if the first character is one of <code>'1', 't', 'T', 'y', 'Y'</code>. This means that strings like <code>"true"</code> and <code>"yes"</code> are recognized as <code>true</code>, while strings like <code>"false"</code> and <code>"no"</code> are recognized as <code>false</code>. For more complex matching you&#8217;ll have to write your own function.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+<code>as_llong</code> and <code>as_ullong</code> are only available if your platform has reliable support for the <code>long long</code> type, including string conversions.
+</td>
+</tr>
+</table>
+</div>
+<div id="code_traverse_base_data" class="paragraph">
+<p>This is an example of using these functions, along with node data retrieval ones (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">);</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;: AllowRemote &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;AllowRemote&quot;</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, Timeout &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Timeout&quot;</span><span class="tok-p">).</span><span class="tok-n">as_int</span><span class="tok-p">();</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, Description &#39;&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">&quot;Description&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;&#39;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.contents"><a class="anchor" href="#access.contents"></a>5.4. Contents-based traversal functions</h3>
+<div class="paragraph">
+<p><a id="xml_node::child"></a><a id="xml_node::attribute"></a><a id="xml_node::next_sibling_name"></a><a id="xml_node::previous_sibling_name"></a>
+Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">next_sibling</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">previous_sibling</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>child</code> and <code>attribute</code> return the first child/attribute with the specified name; <code>next_sibling</code> and <code>previous_sibling</code> return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node/attribute with the specified name, null handle is returned.</p>
+</div>
+<div class="paragraph">
+<p><code>child</code> and <code>next_sibling</code> functions can be used together to loop through all child nodes with the desired name like this:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">);</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span></code></pre>
+</div>
+</div>
+<div id="xml_node::find_child_by_attribute" class="paragraph">
+<p>Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: <code>&lt;group&gt;&lt;item id="1"/&gt; &lt;item id="2"/&gt;&lt;/group&gt;</code>. There are two functions for finding child nodes based on the attribute values:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_child_by_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_value</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_child_by_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_value</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive.</p>
+</div>
+<div class="paragraph">
+<p>In all of the above functions, all arguments have to be valid strings; passing null pointers results in undefined behavior.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of using these functions (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool for *.dae generation: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child_by_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">,</span> <span class="tok-s">&quot;OutputFileMasks&quot;</span><span class="tok-p">,</span> <span class="tok-s">&quot;*.dae&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">);</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.rangefor"><a class="anchor" href="#access.rangefor"></a>5.5. Range-based for-loop support</h3>
+<div class="paragraph">
+<p><a id="xml_node::children"></a><a id="xml_node::attributes"></a>
+If your C&#43;&#43; compiler supports range-based for-loop (this is a C&#43;&#43;11 feature, at the time of writing it&#8217;s supported by Microsoft Visual Studio 2012+, GCC 4.6+ and Clang 3.0+), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with <a href="http://www.boost.org/libs/foreach/">Boost Foreach</a>, and possibly other pre-C&#43;&#43;11 foreach facilities.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">children</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n"><em>implementation</em></span><span class="tok-o">-</span><span class="tok-n"><em>defined</em></span><span class="tok-o">-</span><span class="tok-n"><em>type</em></span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attributes</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>children</code> function allows you to enumerate all child nodes; <code>children</code> function with <code>name</code> argument allows you to enumerate all child nodes with a specific name; <code>attributes</code> function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using <code>children()</code>.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of using these functions (<a href="samples/traverse_rangefor.cpp" class="bare">samples/traverse_rangefor.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-nl">tool</span><span class="tok-p">:</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-nl">attr</span><span class="tok-p">:</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attributes</span><span class="tok-p">())</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-nl">child</span><span class="tok-p">:</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">())</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, child &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.iterators"><a class="anchor" href="#access.iterators"></a>5.6. Traversing node/attribute lists via iterators</h3>
+<div class="paragraph">
+<p><a id="xml_node_iterator"></a><a id="xml_attribute_iterator"></a><a id="xml_node::begin"></a><a id="xml_node::end"></a><a id="xml_node::attributes_begin"></a><a id="xml_node::attributes_end"></a>
+Child node lists and attribute lists are simply double-linked lists; while you can use <code>previous_sibling</code>/<code>next_sibling</code> and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">class</span> <span class="tok-nc">xml_node_iterator</span><span class="tok-p">;</span>
+<span class="tok-k">class</span> <span class="tok-nc">xml_attribute_iterator</span><span class="tok-p">;</span>
+
+<span class="tok-k">typedef</span> <span class="tok-n">xml_node_iterator</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">iterator</span><span class="tok-p">;</span>
+<span class="tok-n">iterator</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">begin</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">iterator</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">end</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">typedef</span> <span class="tok-n">xml_attribute_iterator</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attribute_iterator</span><span class="tok-p">;</span>
+<span class="tok-n">attribute_iterator</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attributes_begin</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">attribute_iterator</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">attributes_end</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>begin</code> and <code>attributes_begin</code> return iterators that point to the first node/attribute, respectively; <code>end</code> and <code>attributes_end</code> return past-the-end iterator for node/attribute list, respectively - this iterator can&#8217;t be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: <code>xml_node_iterator(node)</code>. For <code>xml_attribute_iterator</code>, you&#8217;ll have to provide both an attribute and its parent node.</p>
+</div>
+<div class="paragraph">
+<p><code>begin</code> and <code>end</code> return equal iterators if called on null node; such iterators can&#8217;t be dereferenced. <code>attributes_begin</code> and <code>attributes_end</code> behave the same way. For correct iterator usage this means that child node/attribute collections of null nodes appear to be empty.</p>
+</div>
+<div class="paragraph">
+<p>Both types of iterators have bidirectional iterator semantics (i.e. they can be incremented and decremented, but efficient random access is not supported) and support all usual iterator operations - comparison, dereference, etc. The iterators are invalidated if the node/attribute objects they&#8217;re pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.</p>
+</div>
+<div class="paragraph">
+<p>Here is an example of using iterators for document traversal (<a href="samples/traverse_iter.cpp" class="bare">samples/traverse_iter.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node_iterator</span> <span class="tok-n">it</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">begin</span><span class="tok-p">();</span> <span class="tok-n">it</span> <span class="tok-o">!=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">end</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute_iterator</span> <span class="tok-n">ait</span> <span class="tok-o">=</span> <span class="tok-n">it</span><span class="tok-o">-&gt;</span><span class="tok-n">attributes_begin</span><span class="tok-p">();</span> <span class="tok-n">ait</span> <span class="tok-o">!=</span> <span class="tok-n">it</span><span class="tok-o">-&gt;</span><span class="tok-n">attributes_end</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">ait</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">ait</span><span class="tok-o">-&gt;</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">ait</span><span class="tok-o">-&gt;</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference using assignment - i.e. passing iterators to a function like <code>std::sort</code> - will not give expected results, as assignment modifies local handle that&#8217;s stored in the iterator.
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.walker"><a class="anchor" href="#access.walker"></a>5.7. Recursive traversal with xml_tree_walker</h3>
+<div id="xml_tree_walker" class="paragraph">
+<p>The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you&#8217;ll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement <code>xml_tree_walker</code> interface and to call <code>traverse</code> function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">class</span> <span class="tok-nc">xml_tree_walker</span>
+<span class="tok-p">{</span>
+<span class="tok-k">public</span><span class="tok-o">:</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <span class="tok-n">begin</span><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <span class="tok-n">for_each</span><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">;</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <span class="tok-nf">end</span><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">int</span> <span class="tok-n">depth</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-p">};</span>
+
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">traverse</span><span class="tok-p">(</span><span class="tok-n">xml_tree_walker</span><span class="tok-o">&amp;</span> <span class="tok-n">walker</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="xml_tree_walker::begin"></a><a id="xml_tree_walker::for_each"></a><a id="xml_tree_walker::end"></a><a id="xml_node::traverse"></a>
+The traversal is launched by calling <code>traverse</code> function on traversal root and proceeds as follows:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>First, <code>begin</code> function is called with traversal root as its argument.</p>
+</li>
+<li>
+<p>Then, <code>for_each</code> function is called for all nodes in the traversal subtree in depth first order, excluding the traversal root. Node is passed as an argument.</p>
+</li>
+<li>
+<p>Finally, <code>end</code> function is called with traversal root as its argument.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>If <code>begin</code>, <code>end</code> or any of the <code>for_each</code> calls return <code>false</code>, the traversal is terminated and <code>false</code> is returned as the traversal result; otherwise, the traversal results in <code>true</code>. Note that you don&#8217;t have to override <code>begin</code> or <code>end</code> functions; their default implementations return <code>true</code>.</p>
+</div>
+<div id="xml_tree_walker::depth" class="paragraph">
+<p>You can get the node&#8217;s depth relative to the traversal root at any point by calling <code>depth</code> function. It returns <code>-1</code> if called from <code>begin</code>/<code>end</code>, and returns 0-based depth if called from <code>for_each</code> - depth is 0 for all children of the traversal root, 1 for all grandchildren and so on.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of traversing tree hierarchy with xml_tree_walker (<a href="samples/traverse_walker.cpp" class="bare">samples/traverse_walker.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">struct</span> <span class="tok-nl">simple_walker</span><span class="tok-p">:</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_tree_walker</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <span class="tok-n">for_each</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">i</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">;</span> <span class="tok-n">i</span> <span class="tok-o">&lt;</span> <span class="tok-n">depth</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">i</span><span class="tok-p">)</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span><span class="tok-p">;</span> <span class="tok-c1">// indentation</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node_types</span><span class="tok-p">[</span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">type</span><span class="tok-p">()]</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;: name=&#39;&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;&#39;, value=&#39;&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;&#39;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">return</span> <span class="tok-nb">true</span><span class="tok-p">;</span> <span class="tok-c1">// continue traversal</span>
+ <span class="tok-p">}</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">simple_walker</span> <span class="tok-n">walker</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">traverse</span><span class="tok-p">(</span><span class="tok-n">walker</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.predicate"><a class="anchor" href="#access.predicate"></a>5.8. Searching for nodes/attributes with predicates</h3>
+<div class="paragraph">
+<p><a id="xml_node::find_attribute"></a><a id="xml_node::find_child"></a><a id="xml_node::find_node"></a>
+While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of <code>find_</code> functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">template</span> <span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-n">Predicate</span><span class="tok-o">&gt;</span> <span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_attribute</span><span class="tok-p">(</span><span class="tok-n">Predicate</span> <span class="tok-n">pred</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">template</span> <span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-n">Predicate</span><span class="tok-o">&gt;</span> <span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">Predicate</span> <span class="tok-n">pred</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">template</span> <span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-n">Predicate</span><span class="tok-o">&gt;</span> <span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">find_node</span><span class="tok-p">(</span><span class="tok-n">Predicate</span> <span class="tok-n">pred</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The predicate should be either a plain function or a function object which accepts one argument of type <code>xml_attribute</code> (for <code>find_attribute</code>) or <code>xml_node</code> (for <code>find_child</code> and <code>find_node</code>), and returns <code>bool</code>. The predicate is never called with null handle as an argument.</p>
+</div>
+<div class="paragraph">
+<p><code>find_attribute</code> function iterates through all attributes of the specified node, and returns the first attribute for which the predicate returned <code>true</code>. If the predicate returned <code>false</code> for all attributes or if there were no attributes (including the case where the node is null), null attribute is returned.</p>
+</div>
+<div class="paragraph">
+<p><code>find_child</code> function iterates through all child nodes of the specified node, and returns the first node for which the predicate returned <code>true</code>. If the predicate returned <code>false</code> for all nodes or if there were no child nodes (including the case where the node is null), null node is returned.</p>
+</div>
+<div class="paragraph">
+<p><code>find_node</code> function performs a depth-first traversal through the subtree of the specified node (excluding the node itself), and returns the first node for which the predicate returned <code>true</code>. If the predicate returned <code>false</code> for all nodes or if subtree was empty, null node is returned.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of using predicate-based functions (<a href="samples/traverse_predicate.cpp" class="bare">samples/traverse_predicate.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-nf">small_timeout</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">return</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Timeout&quot;</span><span class="tok-p">).</span><span class="tok-n">as_int</span><span class="tok-p">()</span> <span class="tok-o">&lt;</span> <span class="tok-mi">20</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+
+<span class="tok-k">struct</span> <span class="tok-n">allow_remote_predicate</span>
+<span class="tok-p">{</span>
+ <span class="tok-kt">bool</span> <span class="tok-k">operator</span><span class="tok-p">()(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-n">attr</span><span class="tok-p">)</span> <span class="tok-k">const</span>
+ <span class="tok-p">{</span>
+ <span class="tok-k">return</span> <span class="tok-n">strcmp</span><span class="tok-p">(</span><span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">(),</span> <span class="tok-s">&quot;AllowRemote&quot;</span><span class="tok-p">)</span> <span class="tok-o">==</span> <span class="tok-mi">0</span><span class="tok-p">;</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-kt">bool</span> <span class="tok-k">operator</span><span class="tok-p">()(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span><span class="tok-p">)</span> <span class="tok-k">const</span>
+ <span class="tok-p">{</span>
+ <span class="tok-k">return</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;AllowRemote&quot;</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// Find child via predicate (looks for direct children only)</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Find node via predicate (looks for all descendants in depth-first order)</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">find_node</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Find attribute via predicate</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">find_attribute</span><span class="tok-p">(</span><span class="tok-n">allow_remote_predicate</span><span class="tok-p">()).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// We can use simple functions instead of function objects</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child</span><span class="tok-p">(</span><span class="tok-n">small_timeout</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.text"><a class="anchor" href="#access.text"></a>5.9. Working with text contents</h3>
+<div id="xml_text" class="paragraph">
+<p>It is common to store data as text contents of some node - i.e. <code>&lt;node&gt;&lt;description&gt;This is a node&lt;/description&gt;&lt;/node&gt;</code>. In this case, <code>&lt;description&gt;</code> node does not have a value, but instead has a child of type <a href="#node_pcdata">node_pcdata</a> with value <code>"This is a node"</code>. pugixml provides a special class, <code>xml_text</code>, to work with such data. Working with text objects to modify data is described in <a href="#modify.text">the documentation for modifying document data</a>; this section describes the access interface of <code>xml_text</code>.</p>
+</div>
+<div id="xml_node::text" class="paragraph">
+<p>You can get the text object from a node by using <code>text()</code> method:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_text</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">text</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If the node has a type <code>node_pcdata</code> or <code>node_cdata</code>, then the node itself is used to return data; otherwise, a first child node of type <code>node_pcdata</code> or <code>node_cdata</code> is used.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_text::empty"></a><a id="xml_text::unspecified_bool_type"></a>
+You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. <code>if (text) { &#8230;&#8203; }</code> or <code>if (!text) { &#8230;&#8203; }</code>. Alternatively you can check it by using the <code>empty()</code> method:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">empty</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div id="xml_text::get" class="paragraph">
+<p>Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">get</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In case text object is empty, the function returns an empty string - it never returns a null pointer.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_text::as_string"></a><a id="xml_text::as_int"></a><a id="xml_text::as_uint"></a><a id="xml_text::as_double"></a><a id="xml_text::as_float"></a><a id="xml_text::as_bool"></a><a id="xml_text::as_llong"></a><a id="xml_text::as_ullong"></a>
+If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_string</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">int</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_int</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_uint</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">double</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_double</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">float</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_float</span><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_bool</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-nb">false</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_llong</span><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">as_ullong</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>All of the above functions have the same semantics as similar <code>xml_attribute</code> members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can <a href="#xml_attribute::as_int">refer to documentation for the attribute functions</a> for details.</p>
+</div>
+<div id="xml_text::data" class="paragraph">
+<p><code>xml_text</code> is essentially a helper class that operates on <code>xml_node</code> values. It is bound to a node of type <a href="#node_pcdata">node_pcdata</a> or <a href="#node_cdata">node_cdata</a>. You can use the following function to retrieve this node:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">data</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Essentially, assuming <code>text</code> is an <code>xml_text</code> object, calling <code>text.get()</code> is equivalent to calling <code>text.data().value()</code>.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of using <code>xml_text</code> object (<a href="samples/text.cpp" class="bare">samples/text.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Project name: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">get</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Project version: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;version&quot;</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">as_double</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Project visibility: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-p">(</span><span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;public&quot;</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">as_bool</span><span class="tok-p">(</span><span class="tok-cm">/* def= */</span> <span class="tok-nb">true</span><span class="tok-p">)</span> <span class="tok-o">?</span> <span class="tok-s">&quot;public&quot;</span> <span class="tok-o">:</span> <span class="tok-s">&quot;private&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Project description: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;description&quot;</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">get</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="access.misc"><a class="anchor" href="#access.misc"></a>5.10. Miscellaneous functions</h3>
+<div id="xml_node::root" class="paragraph">
+<p>If you need to get the document root of some node, you can use the following function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">root</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This function returns the node with type <a href="#node_document">node_document</a>, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_node::path"></a><a id="xml_node::first_element_by_path"></a>
+While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">string_t</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">path</span><span class="tok-p">(</span><span class="tok-kt">char_t</span> <span class="tok-n">delimiter</span> <span class="tok-o">=</span> <span class="tok-sc">&#39;/&#39;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">first_element_by_path</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-kt">char_t</span> <span class="tok-n">delimiter</span> <span class="tok-o">=</span> <span class="tok-sc">&#39;/&#39;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Node paths consist of node names, separated with a delimiter (which is <code>/</code> by default); also paths can contain self (<code>.</code>) and parent (<code>..</code>) pseudo-names, so that this is a valid path: <code>"../../foo/./bar"</code>. <code>path</code> returns the path to the node from the document root, <code>first_element_by_path</code> looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: <code>&lt;a&gt;&lt;b&gt;&lt;c/&gt;&lt;/b&gt;&lt;/a&gt;</code>, node <code>&lt;c/&gt;</code> has path <code>"a/b/c"</code>; calling <code>first_element_by_path</code> for document with path <code>"a/b"</code> results in node <code>&lt;b/&gt;</code>; calling <code>first_element_by_path</code> for node <code>&lt;a/&gt;</code> with path <code>"../a/./b/../."</code> results in node <code>&lt;a/&gt;</code>; calling <code>first_element_by_path</code> with path <code>"/a"</code> results in node <code>&lt;a/&gt;</code> for any node.</p>
+</div>
+<div class="paragraph">
+<p>In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of <code>first_element_by_path</code> is null node; also <code>first_element_by_path</code> returns null node for null nodes, in which case the path does not matter. <code>path</code> returns an empty string for null nodes.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+<code>path</code> function returns the result as STL string, and thus is not available if <a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a> is defined.
+</td>
+</tr>
+</table>
+</div>
+<div id="xml_node::offset_debug" class="paragraph">
+<p>pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">ptrdiff_t</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">offset_debug</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node&#8217;s data from the beginning of XML buffer in <a href="#char_t">pugi::char_t</a> units. For more information on parsing offsets, see <a href="#xml_parse_result::offset">parsing error handling documentation</a>.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="modify"><a class="anchor" href="#modify"></a>6. Modifying document data</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. This section provides documentation for the relevant functions. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.</p>
+</div>
+<div class="paragraph">
+<p>All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: <code>void foo(const pugi::xml_node&amp; n) { pugi::xml_node nc = n; }</code>, so const-correctness here mainly provides additional documentation.</p>
+</div>
+<div class="sect2">
+<h3 id="modify.nodedata"><a class="anchor" href="#modify.nodedata"></a>6.1. Setting node data</h3>
+<div class="paragraph">
+<p><a id="xml_node::set_name"></a><a id="xml_node::set_value"></a>
+As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <a href="#node_document">node_document</a> nodes do not have a name or value, <a href="#node_element">node_element</a> and <a href="#node_declaration">node_declaration</a> nodes always have a name but never have a value, <a href="#node_pcdata">node_pcdata</a>, <a href="#node_cdata">node_cdata</a>, <a href="#node_comment">node_comment</a> and <a href="#node_doctype">node_doctype</a> nodes never have a name but always have a value (it may be empty though), <a href="#node_pi">node_pi</a> nodes always have a name and a value (again, value may be empty). In order to set node&#8217;s name or value, you can use the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call <code>set_name</code> on a <a href="#node_pcdata">node_pcdata</a> node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of setting node name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// change node name</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">&quot;notnode&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, new node name: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// change comment text</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;useless comment&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, new comment text: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// we can&#39;t change value of the element or name of the comment</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;1&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">&quot;2&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.attrdata"><a class="anchor" href="#modify.attrdata"></a>6.2. Setting attribute data</h3>
+<div class="paragraph">
+<p><a id="xml_attribute::set_name"></a><a id="xml_attribute::set_value"></a>
+All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the attribute handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.</p>
+</div>
+<div class="paragraph">
+<p>In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The above functions convert the argument to string and then call the base <code>set_value</code> function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either <code>"true"</code> or <code>"false"</code>.</p>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+Number conversion functions depend on current C locale as set with <code>setlocale</code>, so may generate unexpected results if the locale is different from <code>"C"</code>.
+</td>
+</tr>
+</table>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+<code>set_value</code> overloads with <code>long long</code> type are only available if your platform has reliable support for the type, including string conversions.
+</td>
+</tr>
+</table>
+</div>
+<div id="xml_attribute::assign" class="paragraph">
+<p>For convenience, all <code>set_value</code> functions have the corresponding assignment operators:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_attribute</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These operators simply call the right <code>set_value</code> function and return the attribute they&#8217;re called on; the return value of <code>set_value</code> is ignored, so errors are ignored.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of setting attribute name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-n">attr</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;id&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// change attribute name/value</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">&quot;key&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;345&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, new attribute: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// we can use numbers or booleans</span>
+<span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-mf">1.234</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;new attribute value: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// we can also use assignment operators for more concise code</span>
+<span class="tok-n">attr</span> <span class="tok-o">=</span> <span class="tok-nb">true</span><span class="tok-p">;</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;final attribute value: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.add"><a class="anchor" href="#modify.add"></a>6.3. Adding nodes/attributes</h3>
+<div class="paragraph">
+<p><a id="xml_node::prepend_attribute"></a><a id="xml_node::append_attribute"></a><a id="xml_node::insert_attribute_after"></a><a id="xml_node::insert_attribute_before"></a><a id="xml_node::prepend_child"></a><a id="xml_node::append_child"></a><a id="xml_node::insert_child_after"></a><a id="xml_node::insert_child_before"></a>
+Nodes and attributes do not exist without a document tree, so you can&#8217;t create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">prepend_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_attribute_after</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_attribute_before</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span> <span class="tok-o">=</span> <span class="tok-n">node_element</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">prepend_child</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span> <span class="tok-o">=</span> <span class="tok-n">node_element</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_child_after</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">prepend_child</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_child_after</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>append_attribute</code> and <code>append_child</code> create a new node/attribute at the end of the corresponding list of the node the method is called on; <code>prepend_attribute</code> and <code>prepend_child</code> create a new node/attribute at the beginning of the list; <code>insert_attribute_after</code>, <code>insert_attribute_before</code>, <code>insert_child_after</code> and <code>insert_attribute_before</code> add the node/attribute before or after the specified node/attribute.</p>
+</div>
+<div class="paragraph">
+<p>Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the <code>type</code> argument create the node with the specified type; since node type can&#8217;t be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the <code>name</code> argument create the element node (<a href="#node_element">node_element</a>) with the specified name.</p>
+</div>
+<div class="paragraph">
+<p>All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Adding fails if the target node is null;</p>
+</li>
+<li>
+<p>Only <a href="#node_element">node_element</a> nodes can contain attributes, so attribute adding fails if node is not an element;</p>
+</li>
+<li>
+<p>Only <a href="#node_document">node_document</a> and <a href="#node_element">node_element</a> nodes can contain children, so child node adding fails if the target node is not an element or a document;</p>
+</li>
+<li>
+<p><a href="#node_document">node_document</a> and <a href="#node_null">node_null</a> nodes can not be inserted as children, so passing <a href="#node_document">node_document</a> or <a href="#node_null">node_null</a> value as <code>type</code> results in operation failure;</p>
+</li>
+<li>
+<p><a href="#node_declaration">node_declaration</a> nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails;</p>
+</li>
+<li>
+<p>Adding node/attribute results in memory allocation, which may fail;</p>
+</li>
+<li>
+<p>Insertion functions fail if the specified node or attribute is null or is not in the target node&#8217;s children/attribute list.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Even if the operation fails, the document remains in consistent state, but the requested node/attribute is not added.</p>
+</div>
+<div class="admonitionblock caution">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+<code>attribute()</code> and <code>child()</code> functions do not add attributes or nodes to the tree, so code like <code>node.attribute("id") = 123;</code> will not do anything if <code>node</code> does not have an attribute with name <code>"id"</code>. Make sure you&#8217;re operating with existing attributes/nodes by adding them if necessary.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>This is an example of adding new attributes/nodes to the document (<a href="samples/modify_add.cpp" class="bare">samples/modify_add.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// add node with some name</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add description node with text child</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">descr</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">&quot;description&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">descr</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pcdata</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;Simple node&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add param node before the description</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">param</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-s">&quot;param&quot;</span><span class="tok-p">,</span> <span class="tok-n">descr</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add attributes to param node</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-s">&quot;version&quot;</span><span class="tok-p">;</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;value&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-mf">1.1</span><span class="tok-p">;</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">insert_attribute_after</span><span class="tok-p">(</span><span class="tok-s">&quot;type&quot;</span><span class="tok-p">,</span> <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">))</span> <span class="tok-o">=</span> <span class="tok-s">&quot;float&quot;</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.remove"><a class="anchor" href="#modify.remove"></a>6.4. Removing nodes/attributes</h3>
+<div class="paragraph">
+<p><a id="xml_node::remove_attribute"></a><a id="xml_node::remove_child"></a>
+If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">a</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>remove_attribute</code> removes the attribute from the attribute list of the node, and returns the operation result. <code>remove_child</code> removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. Removing fails if one of the following is true:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>The node the function is called on is null;</p>
+</li>
+<li>
+<p>The attribute/node to be removed is null;</p>
+</li>
+<li>
+<p>The attribute/node to be removed is not in the node&#8217;s attribute/child list.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed.</p>
+</div>
+<div class="paragraph">
+<p>If you want to remove the attribute or child node by its name, two additional helper functions are available:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns <code>false</code>; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: <code>while (node.remove_child("tool")) ;</code>.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of removing attributes/nodes from the document (<a href="samples/modify_remove.cpp" class="bare">samples/modify_remove.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// remove description node with the whole subtree</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-s">&quot;description&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// remove id attribute</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">param</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;param&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;value&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// we can also remove nodes/attributes by handles</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-n">id</span> <span class="tok-o">=</span> <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-n">id</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.text"><a class="anchor" href="#modify.text"></a>6.5. Working with text contents</h3>
+<div class="paragraph">
+<p>pugixml provides a special class, <code>xml_text</code>, to work with text contents stored as a value of some node, i.e. <code>&lt;node&gt;&lt;description&gt;This is a node&lt;/description&gt;&lt;/node&gt;</code>. Working with text objects to retrieve data is described in <a href="#access.text">the documentation for accessing document data</a>; this section describes the modification interface of <code>xml_text</code>.</p>
+</div>
+<div id="xml_text::set" class="paragraph">
+<p>Once you have an <code>xml_text</code> object, you can set the text contents using the following function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a <a href="#node_declaration">node_declaration</a> node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from an element node, this function creates the PCDATA child node if necessary (i.e. if the element node does not have a PCDATA/CDATA child already).</p>
+</div>
+<div id="xml_text::set_value" class="paragraph">
+<p>In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The above functions convert the argument to string and then call the base <code>set</code> function. These functions have the same semantics as similar <code>xml_attribute</code> functions. You can <a href="#xml_attribute::set_value">refer to documentation for the attribute functions</a> for details.</p>
+</div>
+<div id="xml_text::assign" class="paragraph">
+<p>For convenience, all <code>set</code> functions have the corresponding assignment operators:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+<span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <span class="tok-n">xml_text</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-o">=</span><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These operators simply call the right <code>set</code> function and return the attribute they&#8217;re called on; the return value of <code>set</code> is ignored, so errors are ignored.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of using <code>xml_text</code> object to modify text contents (<a href="samples/text.cpp" class="bare">samples/text.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// change project version</span>
+<span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;version&quot;</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">()</span> <span class="tok-o">=</span> <span class="tok-mf">1.2</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// add description element and set the contents</span>
+<span class="tok-c1">// note that we do not have to explicitly add the node_pcdata child</span>
+<span class="tok-n">project</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">&quot;description&quot;</span><span class="tok-p">).</span><span class="tok-n">text</span><span class="tok-p">().</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">&quot;a test project&quot;</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.clone"><a class="anchor" href="#modify.clone"></a>6.6. Cloning nodes/attributes</h3>
+<div class="paragraph">
+<p><a id="xml_node::prepend_copy"></a><a id="xml_node::append_copy"></a><a id="xml_node::insert_copy_after"></a><a id="xml_node::insert_copy_before"></a>
+With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can&#8217;t create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">prepend_copy</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_copy_after</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_copy_before</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">prepend_copy</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_copy_after</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_copy_before</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions mirror the structure of <code>append_child</code>, <code>prepend_child</code>, <code>insert_child_before</code> and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure.</p>
+</div>
+<div class="paragraph">
+<p>The attribute is copied along with the name and value; the node is copied along with its type, name and value; additionally attribute list and all children are recursively cloned, resulting in the deep subtree clone. The prototype object can be a part of the same document, or a part of any other document.</p>
+</div>
+<div class="paragraph">
+<p>The failure conditions resemble those of <code>append_child</code>, <code>insert_child_before</code> and related functions, <a href="#xml_node::append_child">consult their documentation for more information</a>. There are additional caveats specific to cloning functions:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Cloning null handles results in operation failure;</p>
+</li>
+<li>
+<p>Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since <a href="#node_document">node_document</a> is not a valid insertion type. The example below provides a workaround.</p>
+</li>
+<li>
+<p>It is possible to copy a subtree as a child of some node inside this subtree, i.e. <code>node.append_copy(node.parent().parent());</code>. This is a valid operation, and it results in a clone of the subtree in the state before cloning started, i.e. no infinite recursion takes place.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This is an example with one possible implementation of include tags in XML (<a href="samples/include.cpp" class="bare">samples/include.cpp</a>). It illustrates node cloning and usage of other document modification functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-nf">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&amp;</span> <span class="tok-n">doc</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">);</span>
+
+<span class="tok-kt">bool</span> <span class="tok-nf">preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span> <span class="tok-n">child</span><span class="tok-p">;</span> <span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">type</span><span class="tok-p">()</span> <span class="tok-o">==</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pi</span> <span class="tok-o">&amp;&amp;</span> <span class="tok-n">strcmp</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">(),</span> <span class="tok-s">&quot;include&quot;</span><span class="tok-p">)</span> <span class="tok-o">==</span> <span class="tok-mi">0</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">include</span> <span class="tok-o">=</span> <span class="tok-n">child</span><span class="tok-p">;</span>
+
+ <span class="tok-c1">// load new preprocessed document (note: ideally this should handle relative paths)</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span> <span class="tok-o">=</span> <span class="tok-n">include</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span>
+
+ <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+ <span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">,</span> <span class="tok-n">path</span><span class="tok-p">))</span> <span class="tok-k">return</span> <span class="tok-nb">false</span><span class="tok-p">;</span>
+
+ <span class="tok-c1">// insert the comment marker above include directive</span>
+ <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_comment</span><span class="tok-p">,</span> <span class="tok-n">include</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-n">path</span><span class="tok-p">);</span>
+
+ <span class="tok-c1">// copy the document above the include directive (this retains the original order!)</span>
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">ic</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span> <span class="tok-n">ic</span><span class="tok-p">;</span> <span class="tok-n">ic</span> <span class="tok-o">=</span> <span class="tok-n">ic</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_copy_before</span><span class="tok-p">(</span><span class="tok-n">ic</span><span class="tok-p">,</span> <span class="tok-n">include</span><span class="tok-p">);</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-c1">// remove the include node and move to the next child</span>
+ <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">();</span>
+
+ <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-n">include</span><span class="tok-p">);</span>
+ <span class="tok-p">}</span>
+ <span class="tok-k">else</span>
+ <span class="tok-p">{</span>
+ <span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">preprocess</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">))</span> <span class="tok-k">return</span> <span class="tok-nb">false</span><span class="tok-p">;</span>
+
+ <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-k">return</span> <span class="tok-nb">true</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+
+<span class="tok-kt">bool</span> <span class="tok-nf">load_preprocess</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&amp;</span> <span class="tok-n">doc</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_default</span> <span class="tok-o">|</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">parse_pi</span><span class="tok-p">);</span> <span class="tok-c1">// for &lt;?include?&gt;</span>
+
+ <span class="tok-k">return</span> <span class="tok-n">result</span> <span class="tok-o">?</span> <span class="tok-n">preprocess</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">)</span> <span class="tok-o">:</span> <span class="tok-nb">false</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.move"><a class="anchor" href="#modify.move"></a>6.7. Moving nodes</h3>
+<div class="paragraph">
+<p><a id="xml_node::prepend_move"></a><a id="xml_node::append_move"></a><a id="xml_node::insert_move_after"></a><a id="xml_node::insert_move_before"></a>
+Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_move</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">prepend_move</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_move_after</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+<span class="tok-n">xml_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">insert_move_before</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions mirror the structure of <code>append_copy</code>, <code>prepend_copy</code>, <code>insert_copy_before</code> and <code>insert_copy_after</code> - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.</p>
+</div>
+<div class="paragraph">
+<p>The failure conditions resemble those of <code>append_child</code>, <code>insert_child_before</code> and related functions, <a href="#xml_node::append_child">consult their documentation for more information</a>. There are additional caveats specific to moving functions:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Moving null handles results in operation failure;</p>
+</li>
+<li>
+<p>Moving is only possible for nodes that belong to the same document; attempting to move nodes between documents will fail.</p>
+</li>
+<li>
+<p><code>insert_move_after</code> and <code>insert_move_before</code> functions fail if the moved node is the same as the <code>node</code> argument (this operation would be a no-op otherwise).</p>
+</li>
+<li>
+<p>It is impossible to move a subtree to a child of some node inside this subtree, i.e. <code>node.append_move(node.parent().parent());</code> will fail.</p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="modify.fragments"><a class="anchor" href="#modify.fragments"></a>6.8. Assembling document from fragments</h3>
+<div id="xml_node::append_buffer" class="paragraph">
+<p>pugixml provides several ways to assemble an XML document from other XML documents. Assuming there is a set of document fragments, represented as in-memory buffers, the implementation choices are as follows:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:</p>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-nf">append_fragment</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">target</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+ <span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-o">!</span><span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">))</span> <span class="tok-k">return</span> <span class="tok-nb">false</span><span class="tok-p">;</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span> <span class="tok-n">child</span><span class="tok-p">;</span> <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span>
+ <span class="tok-n">target</span><span class="tok-p">.</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">);</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</li>
+<li>
+<p>Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment:</p>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-nf">append_fragment</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">target</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span><span class="tok-o">&amp;</span> <span class="tok-n">cached_fragment</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">cached_fragment</span><span class="tok-p">.</span><span class="tok-n">first_child</span><span class="tok-p">();</span> <span class="tok-n">child</span><span class="tok-p">;</span> <span class="tok-n">child</span> <span class="tok-o">=</span> <span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span>
+ <span class="tok-n">target</span><span class="tok-p">.</span><span class="tok-n">append_copy</span><span class="tok-p">(</span><span class="tok-n">child</span><span class="tok-p">);</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</li>
+<li>
+<p>Use <code>xml_node::append_buffer</code> directly:</p>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_parse_result</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">append_buffer</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>The first method is more convenient, but slower than the other two. The relative performance of <code>append_copy</code> and <code>append_buffer</code> depends on the buffer format - usually <code>append_buffer</code> is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending on <code>PUGIXML_WCHAR_MODE</code>). At the same time it might be less efficient in terms of memory usage - the implementation makes a copy of the provided buffer, and the copy has the same lifetime as the document - the memory used by that copy will be reclaimed after the document is destroyed, but no sooner. Even deleting all nodes in the document, including the appended ones, won&#8217;t reclaim the memory.</p>
+</div>
+<div class="paragraph">
+<p><code>append_buffer</code> behaves in the same way as <a href="#xml_document::load_buffer">xml_document::load_buffer</a> - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns.</p>
+</div>
+<div id="status_append_invalid_root" class="paragraph">
+<p>Since <code>append_buffer</code> needs to append child nodes to the current node, it only works if the current node is either document or element node. Calling <code>append_buffer</code> on a node with any other type results in an error with <code>status_append_invalid_root</code> status.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="saving"><a class="anchor" href="#saving"></a>7. Saving document</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format (see <a href="#saving.options">Output options</a>), and also perform necessary encoding conversions (see <a href="#saving.encoding">Encodings</a>). This section documents the relevant functionality.</p>
+</div>
+<div class="paragraph">
+<p>Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as <code>&lt;</code> and <code>&amp;</code>, are properly escaped (unless <a href="#format_no_escapes">format_no_escapes</a> flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as <code>":anonymous"</code>. For well-formed output, make sure all node and attribute names are set to meaningful values.</p>
+</div>
+<div class="paragraph">
+<p>CDATA sections with values that contain <code>"]]&gt;"</code> are split into several sections as follows: section with value <code>"pre]]&gt;post"</code> is written as <code>&lt;![CDATA[pre]]]]&gt;&lt;![CDATA[&gt;post]]&gt;</code>. While this alters the structure of the document (if you load the document after saving it, there will be two CDATA sections instead of one), this is the only way to escape CDATA contents.</p>
+</div>
+<div class="sect2">
+<h3 id="saving.file"><a class="anchor" href="#saving.file"></a>7.1. Saving document to a file</h3>
+<div class="paragraph">
+<p><a id="xml_document::save_file"></a><a id="xml_document::save_file_wide"></a>
+If you want to save the whole document to a file, you can use one of the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see <a href="#saving.options">Output options</a>) and output data encoding (see <a href="#saving.encoding">Encodings</a>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.</p>
+</div>
+<div class="paragraph">
+<p>File path is passed to the system file opening function as is in case of the first function (which accepts <code>const char* path</code>); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.</p>
+</div>
+<div id="xml_writer_file" class="paragraph">
+<p><code>save_file</code> opens the target file for writing, outputs the requested header (by default a document declaration is output, unless the document already has one), and then saves the document contents. If the file could not be opened, the function returns <code>false</code>. Calling <code>save_file</code> is equivalent to creating an <code>xml_writer_file</code> object with <code>FILE*</code> handle as the only constructor argument and then calling <code>save</code>; see <a href="#saving.writer">Saving document via writer interface</a> for writer interface details.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of saving XML document to file (<a href="samples/save_file.cpp" class="bare">samples/save_file.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// save document to file</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Saving result: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-s">&quot;save_file_output.xml&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="saving.stream"><a class="anchor" href="#saving.stream"></a>7.2. Saving document to C&#43;&#43; IOstreams</h3>
+<div id="xml_document::save_stream" class="paragraph">
+<p>To enhance interoperability pugixml provides functions for saving document to any object which implements C&#43;&#43; <code>std::ostream</code> interface. This allows you to save documents to any standard C&#43;&#43; stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use <code>std::cout</code> stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">void</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">void</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>save</code> with <code>std::ostream</code> argument saves the document to the stream in the same way as <code>save_file</code> (i.e. with requested header and with encoding conversions). On the other hand, <code>save</code> with <code>std::wstream</code> argument saves the document to the wide stream with <a href="#encoding_wchar">encoding_wchar</a> encoding. Because of this, using <code>save</code> with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the <code>imbue</code> function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale.</p>
+</div>
+<div id="xml_writer_stream" class="paragraph">
+<p>Calling <code>save</code> with stream target is equivalent to creating an <code>xml_writer_stream</code> object with stream as the only constructor argument and then calling <code>save</code>; see <a href="#saving.writer">Saving document via writer interface</a> for writer interface details.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of saving XML document to standard output (<a href="samples/save_stream.cpp" class="bare">samples/save_stream.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// save document to standard output</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Document:</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="saving.writer"><a class="anchor" href="#saving.writer"></a>7.3. Saving document via writer interface</h3>
+<div class="paragraph">
+<p><a id="xml_document::save"></a><a id="xml_writer"></a><a id="xml_writer::write"></a>
+All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">class</span> <span class="tok-nc">xml_writer</span>
+<span class="tok-p">{</span>
+<span class="tok-k">public</span><span class="tok-o">:</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">void</span> <span class="tok-n">write</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">;</span>
+<span class="tok-p">};</span>
+
+<span class="tok-kt">void</span> <span class="tok-n">xml_document</span><span class="tok-o">::</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&amp;</span> <span class="tok-n">writer</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>In order to output the document via some custom transport, for example sockets, you should create an object which implements <code>xml_writer</code> interface and pass it to <code>save</code> function. <code>xml_writer::write</code> function is called with a buffer as an input, where <code>data</code> points to buffer start, and <code>size</code> is equal to the buffer size in bytes. <code>write</code> implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after <code>write</code> returns. The buffer contains the chunk of document data in the desired encoding.</p>
+</div>
+<div class="paragraph">
+<p><code>write</code> function is called with relatively large blocks (size is usually several kilobytes, except for the last block that may be small), so there is often no need for additional buffering in the implementation.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of custom writer for saving document data to STL string (<a href="samples/save_custom_writer.cpp" class="bare">samples/save_custom_writer.cpp</a>); read the sample code for more complex examples:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">struct</span> <span class="tok-nl">xml_string_writer</span><span class="tok-p">:</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_writer</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <span class="tok-n">result</span><span class="tok-p">;</span>
+
+ <span class="tok-k">virtual</span> <span class="tok-kt">void</span> <span class="tok-nf">write</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">append</span><span class="tok-p">(</span><span class="tok-k">static_cast</span><span class="tok-o">&lt;</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*&gt;</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">),</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+ <span class="tok-p">}</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="saving.subtree"><a class="anchor" href="#saving.subtree"></a>7.4. Saving a single subtree</h3>
+<div class="paragraph">
+<p><a id="xml_node::print"></a><a id="xml_node::print_stream"></a>
+While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">void</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&amp;</span> <span class="tok-n">os</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">depth</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">void</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&amp;</span> <span class="tok-n">os</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">depth</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">void</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&amp;</span> <span class="tok-n">writer</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">depth</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions have the same arguments with the same meaning as the corresponding <code>xml_document::save</code> functions, and allow you to save the subtree to either a C&#43;&#43; IOstream or to any object that implements <code>xml_writer</code> interface.</p>
+</div>
+<div class="paragraph">
+<p>Saving a subtree differs from saving the whole document: the process behaves as if <a href="#format_write_bom">format_write_bom</a> is off, and <a href="#format_no_declaration">format_no_declaration</a> is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node&#8217;s children. Note that this also holds if you&#8217;re saving a document; this example (<a href="samples/save_subtree.cpp" class="bare">samples/save_subtree.cpp</a>) illustrates the difference:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// get a test document</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">&quot;&lt;foo bar=&#39;baz&#39;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// print document to standard output (prints &lt;?xml version=&quot;1.0&quot;?&gt;&lt;foo bar=&quot;baz&quot;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;)</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// print document to standard output as a regular node (prints &lt;foo bar=&quot;baz&quot;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;)</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// print a subtree to standard output (prints &lt;call&gt;hey&lt;/call&gt;)</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;foo&quot;</span><span class="tok-p">).</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;call&quot;</span><span class="tok-p">).</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="saving.options"><a class="anchor" href="#saving.options"></a>7.5. Output options</h3>
+<div class="paragraph">
+<p>All saving functions accept the optional parameter <code>flags</code>. This is a bitmask that customizes the output format; you can select the way the document nodes are printed and select the needed additional information that is output before the document contents.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use <code>mask | flag</code>; to disable a flag, use <code>mask &amp; ~flag</code>.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>These flags control the resulting tree contents:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="format_indent"></a><code>format_indent</code> determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is <code>"\t"</code> by default). If this flag is on, before every node the indentation string is output several times, where the amount of indentation depends on the node&#8217;s depth relative to the output subtree. This flag has no effect if <a href="#format_raw">format_raw</a> is enabled. This flag is <strong>on</strong> by default.</p>
+</li>
+<li>
+<p><a id="format_raw"></a><code>format_raw</code> switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with <a href="#parse_ws_pcdata">parse_ws_pcdata</a> flag, to preserve the original document formatting as much as possible. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="format_no_escapes"></a><code>format_no_escapes</code> disables output escaping for attribute values and PCDATA contents. If this flag is off, special symbols (<code>"</code>, <code>&amp;</code>, <code>&lt;</code>, <code>&gt;</code>) and all non-printable characters (those with codepoint values less than 32) are converted to XML escape sequences (i.e. <code>&amp;amp;</code>) during output. If this flag is on, no text processing is performed; therefore, output XML can be malformed if output contents contains invalid symbols (i.e. having a stray <code>&lt;</code> in the PCDATA will make the output malformed). This flag is <strong>off</strong> by default.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>These flags control the additional output information:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="format_no_declaration"></a><code>format_no_declaration</code> disables default node declaration output. By default, if the document is saved via <code>save</code> or <code>save_file</code> function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in <code>xml_node::print</code> functions: they never output the default declaration. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="format_write_bom"></a><code>format_write_bom</code> enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document&#8217;s encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in <code>xml_node::print</code> functions: they never output the BOM. This flag is <strong>off</strong> by default.</p>
+</li>
+<li>
+<p><a id="format_save_file_text"></a><code>format_save_file_text</code> changes the file mode when using <code>save_file</code> function. By default, file is opened in binary mode, which means that the output file will
+contain platform-independent newline <code>\n</code> (ASCII 10). If this flag is on, file is opened in text mode, which on some systems changes the newline format (i.e. on Windows you can use this flag to output XML documents with <code>\r\n</code> (ASCII 13 10) newlines. This flag is <strong>off</strong> by default.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Additionally, there is one predefined option mask:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p><a id="format_default"></a><code>format_default</code> is the default set of flags, i.e. it has all options set to their default values. It sets formatted output with indentation, without BOM and with default node declaration, if necessary.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This is an example that shows the outputs of different output options (<a href="samples/save_options.cpp" class="bare">samples/save_options.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// get a test document</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">&quot;&lt;foo bar=&#39;baz&#39;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// default options; prints</span>
+<span class="tok-c1">// &lt;?xml version=&quot;1.0&quot;?&gt;</span>
+<span class="tok-c1">// &lt;foo bar=&quot;baz&quot;&gt;</span>
+<span class="tok-c1">// &lt;call&gt;hey&lt;/call&gt;</span>
+<span class="tok-c1">// &lt;/foo&gt;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// default options with custom indentation string; prints</span>
+<span class="tok-c1">// &lt;?xml version=&quot;1.0&quot;?&gt;</span>
+<span class="tok-c1">// &lt;foo bar=&quot;baz&quot;&gt;</span>
+<span class="tok-c1">// --&lt;call&gt;hey&lt;/call&gt;</span>
+<span class="tok-c1">// &lt;/foo&gt;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;--&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// default options without indentation; prints</span>
+<span class="tok-c1">// &lt;?xml version=&quot;1.0&quot;?&gt;</span>
+<span class="tok-c1">// &lt;foo bar=&quot;baz&quot;&gt;</span>
+<span class="tok-c1">// &lt;call&gt;hey&lt;/call&gt;</span>
+<span class="tok-c1">// &lt;/foo&gt;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_default</span> <span class="tok-o">&amp;</span> <span class="tok-o">~</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_indent</span><span class="tok-p">);</span> <span class="tok-c1">// can also pass &quot;&quot; instead of indentation string for the same effect</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// raw output; prints</span>
+<span class="tok-c1">// &lt;?xml version=&quot;1.0&quot;?&gt;&lt;foo bar=&quot;baz&quot;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// raw output without declaration; prints</span>
+<span class="tok-c1">// &lt;foo bar=&quot;baz&quot;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">,</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_raw</span> <span class="tok-o">|</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">format_no_declaration</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="saving.encoding"><a class="anchor" href="#saving.encoding"></a>7.6. Encodings</h3>
+<div class="paragraph">
+<p>pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it&#8217;s a strict subset of UTF-16) and handles all encoding conversions during output. The output encoding is set via the <code>encoding</code> parameter of saving functions, which is of type <code>xml_encoding</code>. The possible values for the encoding are documented in <a href="#loading.encoding">Encodings</a>; the only flag that has a different meaning is <code>encoding_auto</code>.</p>
+</div>
+<div class="paragraph">
+<p>While all other flags set the exact encoding, <code>encoding_auto</code> is meant for automatic encoding detection. The automatic detection does not make sense for output encoding, since there is usually nothing to infer the actual encoding from, so here <code>encoding_auto</code> means UTF-8 encoding, which is the most popular encoding for XML data storage. This is also the default value of output encoding; specify another value if you do not want UTF-8 encoded output.</p>
+</div>
+<div class="paragraph">
+<p>Also note that wide stream saving functions do not have <code>encoding</code> argument and always assume <a href="#encoding_wchar">encoding_wchar</a> encoding.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; if your node/attribute names do not contain any valid UTF sequences, they may be output as if they are empty, which will result in malformed XML document.
+</td>
+</tr>
+</table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="saving.declaration"><a class="anchor" href="#saving.declaration"></a>7.7. Customizing document declaration</h3>
+<div class="paragraph">
+<p>When you are saving the document using <code>xml_document::save()</code> or <code>xml_document::save_file()</code>, a default XML document declaration is output, if <code>format_no_declaration</code> is not specified and if the document does not have a declaration node. However, the default declaration is not customizable. If you want to customize the declaration output, you need to create the declaration node yourself.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag <a href="#parse_declaration">parse_declaration</a> to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving.
+</td>
+</tr>
+</table>
+</div>
+<div class="paragraph">
+<p>Declaration node is a node with type <a href="#node_declaration">node_declaration</a>; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values.</p>
+</div>
+<div class="paragraph">
+<p>This is an example that shows how to create a custom declaration node (<a href="samples/save_declaration.cpp" class="bare">samples/save_declaration.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// get a test document</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-s">&quot;&lt;foo bar=&#39;baz&#39;&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add a custom declaration node</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">decl</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">prepend_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_declaration</span><span class="tok-p">);</span>
+<span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;version&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-s">&quot;1.0&quot;</span><span class="tok-p">;</span>
+<span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;encoding&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-s">&quot;UTF-8&quot;</span><span class="tok-p">;</span>
+<span class="tok-n">decl</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;standalone&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-s">&quot;no&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;</span>
+<span class="tok-c1">// &lt;foo bar=&quot;baz&quot;&gt;</span>
+<span class="tok-c1">// &lt;call&gt;hey&lt;/call&gt;</span>
+<span class="tok-c1">// &lt;/foo&gt;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="xpath"><a class="anchor" href="#xpath"></a>8. XPath</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in <a href="#xpath.w3c">Conformance to W3C specification</a>. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read <a href="http://www.w3schools.com/xpath/">W3Schools XPath tutorial</a>, <a href="http://www.tizag.com/xmlTutorial/xpathtutorial.php">XPath tutorial at tizag.com</a>, and <a href="http://www.w3.org/TR/xpath/">the XPath 1.0 specification</a>.</p>
+</div>
+<div class="sect2">
+<h3 id="xpath.types"><a class="anchor" href="#xpath.types"></a>8.1. XPath types</h3>
+<div class="paragraph">
+<p><a id="xpath_value_type"></a><a id="xpath_type_number"></a><a id="xpath_type_string"></a><a id="xpath_type_boolean"></a><a id="xpath_type_node_set"></a><a id="xpath_type_none"></a>
+Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to <code>bool</code> type, number type corresponds to <code>double</code> type, string type corresponds to either <code>std::string</code> or <code>std::wstring</code>, depending on whether <a href="#dom.unicode">wide character interface is enabled</a>, and node set corresponds to <a href="#xpath_node_set">xpath_node_set</a> type. There is an enumeration, <code>xpath_value_type</code>, which can take the values <code>xpath_type_boolean</code>, <code>xpath_type_number</code>, <code>xpath_type_string</code> or <code>xpath_type_node_set</code>, accordingly.</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_node"></a><a id="xpath_node::node"></a><a id="xpath_node::attribute"></a><a id="xpath_node::parent"></a>
+Because an XPath node can be either a node or an attribute, there is a special type, <code>xpath_node</code>, which is a discriminated union of these types. A value of this type contains two node handles, one of <code>xml_node</code> type, and another one of <code>xml_attribute</code> type; at most one of them can be non-null. The accessors to get these handles are available:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xpath_node</span><span class="tok-o">::</span><span class="tok-n">node</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xml_attribute</span> <span class="tok-n">xpath_node</span><span class="tok-o">::</span><span class="tok-n">attribute</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>XPath nodes can be null, in which case both accessors return null handles.</p>
+</div>
+<div class="paragraph">
+<p>Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xml_node</span> <span class="tok-n">xpath_node</span><span class="tok-o">::</span><span class="tok-n">parent</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>parent</code> function returns the node&#8217;s parent if the XPath node corresponds to <code>xml_node</code> handle (equivalent to <code>node().parent()</code>), or the node to which the attribute belongs to, if the XPath node corresponds to <code>xml_attribute</code> handle. For null nodes, <code>parent</code> returns null handle.</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_node::unspecified_bool_type"></a><a id="xpath_node::comparison"></a>
+Like node and attribute handles, XPath node handles can be implicitly cast to boolean-like object to check if it is a null node, and also can be compared for equality with each other.</p>
+</div>
+<div id="xpath_node::ctor" class="paragraph">
+<p>You can also create XPath nodes with one of the three constructors: the default constructor, the constructor that takes node argument, and the constructor that takes attribute and node arguments (in which case the attribute must belong to the attribute list of the node). The constructor from <code>xml_node</code> is implicit, so you can usually pass <code>xml_node</code> to functions that expect <code>xpath_node</code>. Apart from that you usually don&#8217;t need to create your own XPath node objects, since they are returned to you via selection functions.</p>
+</div>
+<div id="xpath_node_set" class="paragraph">
+<p>XPath expressions operate not on single nodes, but instead on node sets. A node set is a collection of nodes, which can be optionally ordered in either a forward document order or a reverse one. Document order is defined in XPath specification; an XPath node is before another node in document order if it appears before it in XML representation of the corresponding document.</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_node_set::const_iterator"></a><a id="xpath_node_set::begin"></a><a id="xpath_node_set::end"></a>
+Node sets are represented by <code>xpath_node_set</code> object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">typedef</span> <span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">*</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span><span class="tok-p">;</span>
+<span class="tok-n">const_iterator</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">begin</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">const_iterator</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">end</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="xpath_node_set::index"></a><a id="xpath_node_set::size"></a><a id="xpath_node_set::empty"></a>
+And it also can be iterated via indices, just like <code>std::vector</code>:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-k">operator</span><span class="tok-p">[](</span><span class="tok-kt">size_t</span> <span class="tok-n">index</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">size_t</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">size</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">empty</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>All of the above operations have the same semantics as that of <code>std::vector</code>: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster.</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_node_set::type"></a><a id="xpath_node_set::type_unsorted"></a><a id="xpath_node_set::type_sorted"></a><a id="xpath_node_set::type_sorted_reverse"></a><a id="xpath_node_set::sort"></a>
+The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">enum</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-kt">type_t</span> <span class="tok-p">{</span><span class="tok-n">type_unsorted</span><span class="tok-p">,</span> <span class="tok-n">type_sorted</span><span class="tok-p">,</span> <span class="tok-n">type_sorted_reverse</span><span class="tok-p">};</span>
+<span class="tok-kt">type_t</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">type</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>type</code> function returns the current order of nodes; <code>type_sorted</code> means that the nodes are in forward document order, <code>type_sorted_reverse</code> means that the nodes are in reverse document order, and <code>type_unsorted</code> means that neither order is guaranteed (nodes can accidentally be in a sorted order even if <code>type()</code> returns <code>type_unsorted</code>). If you require a specific order of iteration, you can change it via <code>sort</code> function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">void</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">sort</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">reverse</span> <span class="tok-o">=</span> <span class="tok-nb">false</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Calling <code>sort</code> sorts the nodes in either forward or reverse document order, depending on the argument; after this call <code>type()</code> will return <code>type_sorted</code> or <code>type_sorted_reverse</code>.</p>
+</div>
+<div id="xpath_node_set::first" class="paragraph">
+<p>Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_node</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">first</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of <code>type()</code>), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.</p>
+</div>
+<div id="xpath_node_set::ctor" class="paragraph">
+<p>While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (<code>const_iterator</code> is a typedef for <code>const xpath_node*</code>), and an optional type:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-p">(</span><span class="tok-n">const_iterator</span> <span class="tok-n">begin</span><span class="tok-p">,</span> <span class="tok-n">const_iterator</span> <span class="tok-n">end</span><span class="tok-p">,</span> <span class="tok-kt">type_t</span> <span class="tok-n">type</span> <span class="tok-o">=</span> <span class="tok-n">type_unsorted</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you&#8217;ll have to ensure that the range contains no duplicates, and that the objects are sorted according to the <code>type</code> parameter. Otherwise XPath operations with this set may produce unexpected results.</p>
+</div>
+</div>
+<div class="sect2">
+<h3 id="xpath.select"><a class="anchor" href="#xpath.select"></a>8.2. Selecting nodes via XPath expression</h3>
+<div class="paragraph">
+<p><a id="xml_node::select_node"></a><a id="xml_node::select_nodes"></a>
+If you want to select nodes that match some XPath expression, you can do it with the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xpath_node_set</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>select_nodes</code> function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. <code>select_node</code> returns only the first node in document order from the result, and is equivalent to calling <code>select_nodes(query).first()</code>. If the XPath expression does not match anything, or the node handle is null, <code>select_nodes</code> returns an empty set, and <code>select_node</code> returns null XPath node.</p>
+</div>
+<div class="paragraph">
+<p>If exception handling is not disabled, both functions throw <a href="#xpath_exception">xpath_exception</a> if the query can not be compiled or if it returns a value with type other than node set; see <a href="#xpath.errors">Error handling</a> for details.</p>
+</div>
+<div class="paragraph">
+<p><a id="xml_node::select_node_precomp"></a><a id="xml_node::select_nodes_precomp"></a>
+While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you&#8217;re doing many similar queries, consider compiling them into query objects (see <a href="#xpath.query">Using query objects</a> for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_query</span><span class="tok-o">&amp;</span> <span class="tok-n">query</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xpath_node_set</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_query</span><span class="tok-o">&amp;</span> <span class="tok-n">query</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If exception handling is not disabled, both functions throw <a href="#xpath_exception">xpath_exception</a> if the query returns a value with type other than node set.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of selecting nodes using XPath expressions (<a href="samples/xpath_select.cpp" class="bare">samples/xpath_select.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span> <span class="tok-n">tools</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">&quot;/Profile/Tools/Tool[@AllowRemote=&#39;true&#39; and @DeriveCaptionFrom=&#39;lastparam&#39;]&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tools:</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span> <span class="tok-n">it</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">begin</span><span class="tok-p">();</span> <span class="tok-n">it</span> <span class="tok-o">!=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">end</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-o">*</span><span class="tok-n">it</span><span class="tok-p">;</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span> <span class="tok-n">build_tool</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-s">&quot;//Tool[contains(Description, &#39;build system&#39;)]&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-n">build_tool</span><span class="tok-p">)</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Build tool: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">build_tool</span><span class="tok-p">.</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="xpath.query"><a class="anchor" href="#xpath.query"></a>8.3. Using query objects</h3>
+<div id="xpath_query" class="paragraph">
+<p>When you call <code>select_nodes</code> with an expression string as an argument, a query object is created behind the scenes. A query object represents a compiled XPath expression. Query objects can be needed in the following circumstances:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>You can precompile expressions to query objects to save compilation time if it becomes an issue;</p>
+</li>
+<li>
+<p>You can use query objects to evaluate XPath expressions which result in booleans, numbers or strings;</p>
+</li>
+<li>
+<p>You can get the type of expression value via query object.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Query objects correspond to <code>xpath_query</code> type. They are immutable and non-copyable: they are bound to the expression at creation time and can not be cloned. If you want to put query objects in a container, allocate them on heap via <code>new</code> operator and store pointers to <code>xpath_query</code> in the container.</p>
+</div>
+<div id="xpath_query::ctor" class="paragraph">
+<p>You can create a query object with the constructor that takes XPath expression as an argument:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">explicit</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div id="xpath_query::return_type" class="paragraph">
+<p>The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, <a href="#xpath_exception">xpath_exception</a> is thrown if exception handling is not disabled (see <a href="#xpath.errors">Error handling</a> for details). After the query is created, you can query the type of the evaluation result using the following function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_value_type</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">return_type</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="xpath_query::evaluate_boolean"></a><a id="xpath_query::evaluate_number"></a><a id="xpath_query::evaluate_string"></a><a id="xpath_query::evaluate_node_set"></a><a id="xpath_query::evaluate_node"></a>
+You can evaluate the query using one of the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">evaluate_boolean</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">double</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">evaluate_number</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">string_t</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">evaluate_string</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xpath_node_set</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xpath_node</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">evaluate_node</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, <code>evaluate_boolean</code>, <code>evaluate_number</code> and <code>evaluate_string</code> always return a result, but <code>evaluate_node_set</code> and <code>evaluate_node</code> result in an error if the return type is not node set (see <a href="#xpath.errors">Error handling</a>).</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+Calling <code>node.select_nodes("query")</code> is equivalent to calling <code>xpath_query("query").evaluate_node_set(node)</code>. Calling <code>node.select_node("query")</code> is equivalent to calling <code>xpath_query("query").evaluate_node(node)</code>.
+</td>
+</tr>
+</table>
+</div>
+<div id="xpath_query::evaluate_string_buffer" class="paragraph">
+<p>Note that <code>evaluate_string</code> function returns the STL string; as such, it&#8217;s not available in <a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a> mode and also usually allocates memory. There is another string evaluation function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">size_t</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">evaluate_string</span><span class="tok-p">(</span><span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">capacity</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This function evaluates the string, and then writes the result to <code>buffer</code> (but at most <code>capacity</code> characters); then it returns the full size of the result in characters, including the terminating zero. If <code>capacity</code> is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>First call the function with <code>buffer = 0</code> and <code>capacity = 0</code>; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters;</p>
+</li>
+<li>
+<p>First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This is an example of using query objects (<a href="samples/xpath_query.cpp" class="bare">samples/xpath_query.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// Select nodes via compiled query</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span> <span class="tok-n">query_remote_tools</span><span class="tok-p">(</span><span class="tok-s">&quot;/Profile/Tools/Tool[@AllowRemote=&#39;true&#39;]&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span> <span class="tok-n">tools</span> <span class="tok-o">=</span> <span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Remote tool: &quot;</span><span class="tok-p">;</span>
+<span class="tok-n">tools</span><span class="tok-p">[</span><span class="tok-mi">2</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// Evaluate numbers via compiled query</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span> <span class="tok-n">query_timeouts</span><span class="tok-p">(</span><span class="tok-s">&quot;sum(//Tool/@Timeout)&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">query_timeouts</span><span class="tok-p">.</span><span class="tok-n">evaluate_number</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// Evaluate strings via compiled query for different context nodes</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span> <span class="tok-n">query_name_valid</span><span class="tok-p">(</span><span class="tok-s">&quot;string-length(substring-before(@Filename, &#39;_&#39;)) &gt; 0 and @OutputFileMasks&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span> <span class="tok-n">query_name</span><span class="tok-p">(</span><span class="tok-s">&quot;concat(substring-before(@Filename, &#39;_&#39;), &#39; produces &#39;, @OutputFileMasks)&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">first_element_by_path</span><span class="tok-p">(</span><span class="tok-s">&quot;Profile/Tools/Tool&quot;</span><span class="tok-p">);</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">())</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <span class="tok-n">s</span> <span class="tok-o">=</span> <span class="tok-n">query_name</span><span class="tok-p">.</span><span class="tok-n">evaluate_string</span><span class="tok-p">(</span><span class="tok-n">tool</span><span class="tok-p">);</span>
+
+ <span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-n">query_name_valid</span><span class="tok-p">.</span><span class="tok-n">evaluate_boolean</span><span class="tok-p">(</span><span class="tok-n">tool</span><span class="tok-p">))</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">s</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="xpath.variables"><a class="anchor" href="#xpath.variables"></a>8.4. Using variables</h3>
+<div class="paragraph">
+<p>XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries.</p>
+</div>
+<div class="paragraph">
+<p>Variable references have the form <code>$name</code>; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to <code>xpath_query</code> constructor or to <code>select_nodes</code>/<code>select_node</code> functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">explicit</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">);</span>
+<span class="tok-n">xpath_node</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xpath_node_set</span> <span class="tok-n">xml_node</span><span class="tok-o">::</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If you&#8217;re using query objects, you can change the variable values before <code>evaluate</code>/<code>select</code> calls to change the query behavior.</p>
+</div>
+<div class="admonitionblock note">
+<table>
+<tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+The variable set pointer is stored in the query object; you have to ensure that the lifetime of the set exceeds that of query object.
+</td>
+</tr>
+</table>
+</div>
+<div id="xpath_variable_set" class="paragraph">
+<p>Variable sets correspond to <code>xpath_variable_set</code> type, which is essentially a variable container.</p>
+</div>
+<div id="xpath_variable_set::add" class="paragraph">
+<p>You can add new variables with the following function:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_variable</span><span class="tok-o">*</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">add</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-n">xpath_value_type</span> <span class="tok-n">type</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure.</p>
+</div>
+<div class="paragraph">
+<p>New variables are assigned the default value which depends on the type: <code>0</code> for numbers, <code>false</code> for booleans, empty string for strings and empty set for node sets.</p>
+</div>
+<div id="xpath_variable_set::get" class="paragraph">
+<p>You can get the existing variables with the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">xpath_variable</span><span class="tok-o">*</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">get</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+<span class="tok-k">const</span> <span class="tok-n">xpath_variable</span><span class="tok-o">*</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">get</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The functions return the variable handle, or null pointer if the variable with the specified name is not found.</p>
+</div>
+<div id="xpath_variable_set::set" class="paragraph">
+<p>Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return <code>false</code>; they also return <code>false</code> on allocation failure. Note that these functions do not perform any type conversions.</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-kt">bool</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-kt">double</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">&amp;</span> <span class="tok-n">value</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.</p>
+</div>
+<div id="xpath_variable" class="paragraph">
+<p>If setting variables by name is not efficient enough, or if you have to inspect variable information or get variable values, you can use variable handles. A variable corresponds to the <code>xpath_variable</code> type, and a variable handle is simply a pointer to <code>xpath_variable</code>.</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_variable::type"></a><a id="xpath_variable::name"></a>
+In order to get variable information, you can use one of the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-n">xpath_value_type</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">type</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_variable::get_boolean"></a><a id="xpath_variable::get_number"></a><a id="xpath_variable::get_string"></a><a id="xpath_variable::get_node_set"></a>
+In order to get variable value, you should use one of the following functions, depending on the variable type:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">get_boolean</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-kt">double</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">get_number</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">get_string</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-k">const</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">&amp;</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">get_node_set</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (<code>false</code> for booleans, <code>NaN</code> for numbers, empty string for strings and empty set for node sets).</p>
+</div>
+<div id="xpath_variable::set" class="paragraph">
+<p>In order to set variable value, you should use one of the following functions, depending on the variable type:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-kt">bool</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+<span class="tok-kt">bool</span> <span class="tok-n">xpath_variable</span><span class="tok-o">::</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">&amp;</span> <span class="tok-n">value</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return <code>false</code>; they also return <code>false</code> on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of using variables in XPath queries (<a href="samples/xpath_variables.cpp" class="bare">samples/xpath_variables.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// Select nodes via compiled query</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_variable_set</span> <span class="tok-n">vars</span><span class="tok-p">;</span>
+<span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">add</span><span class="tok-p">(</span><span class="tok-s">&quot;remote&quot;</span><span class="tok-p">,</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_type_boolean</span><span class="tok-p">);</span>
+
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_query</span> <span class="tok-n">query_remote_tools</span><span class="tok-p">(</span><span class="tok-s">&quot;/Profile/Tools/Tool[@AllowRemote = string($remote)]&quot;</span><span class="tok-p">,</span> <span class="tok-o">&amp;</span><span class="tok-n">vars</span><span class="tok-p">);</span>
+
+<span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">&quot;remote&quot;</span><span class="tok-p">,</span> <span class="tok-nb">true</span><span class="tok-p">);</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span> <span class="tok-n">tools_remote</span> <span class="tok-o">=</span> <span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span>
+
+<span class="tok-n">vars</span><span class="tok-p">.</span><span class="tok-n">set</span><span class="tok-p">(</span><span class="tok-s">&quot;remote&quot;</span><span class="tok-p">,</span> <span class="tok-nb">false</span><span class="tok-p">);</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span> <span class="tok-n">tools_local</span> <span class="tok-o">=</span> <span class="tok-n">query_remote_tools</span><span class="tok-p">.</span><span class="tok-n">evaluate_node_set</span><span class="tok-p">(</span><span class="tok-n">doc</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Remote tool: &quot;</span><span class="tok-p">;</span>
+<span class="tok-n">tools_remote</span><span class="tok-p">[</span><span class="tok-mi">2</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Local tool: &quot;</span><span class="tok-p">;</span>
+<span class="tok-n">tools_local</span><span class="tok-p">[</span><span class="tok-mi">0</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// You can pass the context directly to select_nodes/select_node</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span> <span class="tok-n">tools_local_imm</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">&quot;/Profile/Tools/Tool[@AllowRemote = string($remote)]&quot;</span><span class="tok-p">,</span> <span class="tok-o">&amp;</span><span class="tok-n">vars</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Local tool imm: &quot;</span><span class="tok-p">;</span>
+<span class="tok-n">tools_local_imm</span><span class="tok-p">[</span><span class="tok-mi">0</span><span class="tok-p">].</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="xpath.errors"><a class="anchor" href="#xpath.errors"></a>8.5. Error handling</h3>
+<div class="paragraph">
+<p>There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with <a href="#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a> define).</p>
+</div>
+<div class="paragraph">
+<p><a id="xpath_exception"></a><a id="xpath_exception::result"></a><a id="xpath_exception::what"></a>
+By default, XPath functions throw <code>xpath_exception</code> object in case of errors; additionally, in the event any memory allocation fails, an <code>std::bad_alloc</code> exception is thrown. Also <code>xpath_exception</code> is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">virtual</span> <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">xpath_exception</span><span class="tok-o">::</span><span class="tok-n">what</span><span class="tok-p">()</span> <span class="tok-k">const</span> <span class="tok-k">throw</span><span class="tok-p">();</span>
+<span class="tok-k">const</span> <span class="tok-n">xpath_parse_result</span><span class="tok-o">&amp;</span> <span class="tok-n">xpath_exception</span><span class="tok-o">::</span><span class="tok-n">result</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><a id="xpath_query::unspecified_bool_type"></a><a id="xpath_query::result"></a>
+If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: <code>if (query) { &#8230;&#8203; }</code>. Additionally, you can get parsing result via the result() accessor:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-n">xpath_parse_result</span><span class="tok-o">&amp;</span> <span class="tok-n">xpath_query</span><span class="tok-o">::</span><span class="tok-n">result</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Without exceptions, evaluating invalid query results in <code>false</code>, empty string, <code>NaN</code> or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.</p>
+</div>
+<div id="xpath_parse_result" class="paragraph">
+<p>The information about parsing result is returned via <code>xpath_parse_result</code> object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">struct</span> <span class="tok-n">xpath_parse_result</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">error</span><span class="tok-p">;</span>
+ <span class="tok-kt">ptrdiff_t</span> <span class="tok-n">offset</span><span class="tok-p">;</span>
+
+ <span class="tok-k">operator</span> <span class="tok-kt">bool</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">description</span><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+<div id="xpath_parse_result::error" class="paragraph">
+<p>Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string.</p>
+</div>
+<div id="xpath_parse_result::description" class="paragraph">
+<p><code>description()</code> member function can be used to get the error message; it never returns the null pointer, so you can safely use <code>description()</code> even if query parsing succeeded. Note that <code>description()</code> returns a <code>char</code> string even in <code>PUGIXML_WCHAR_MODE</code>; you&#8217;ll have to call <a href="#as_wide">as_wide</a> to get the <code>wchar_t</code> string.</p>
+</div>
+<div id="xpath_parse_result::offset" class="paragraph">
+<p>In addition to the error message, parsing result has an <code>offset</code> member, which contains the offset of last successfully parsed character. This offset is in units of <a href="#char_t">pugi::char_t</a> (bytes for character mode, wide characters for wide character mode).</p>
+</div>
+<div id="xpath_parse_result::bool" class="paragraph">
+<p>Parsing result object can be implicitly converted to <code>bool</code> like this: <code>if (result) { &#8230;&#8203; } else { &#8230;&#8203; }</code>.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of XPath error handling (<a href="samples/xpath_error.cpp" class="bare">samples/xpath_error.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// Exception is thrown for incorrect query syntax</span>
+<span class="tok-n">try</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">&quot;//nodes[#true()]&quot;</span><span class="tok-p">);</span>
+<span class="tok-p">}</span>
+<span class="tok-k">catch</span> <span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&amp;</span> <span class="tok-n">e</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Select failed: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+
+<span class="tok-c1">// Exception is thrown for incorrect query semantics</span>
+<span class="tok-n">try</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">&quot;(123)/next&quot;</span><span class="tok-p">);</span>
+<span class="tok-p">}</span>
+<span class="tok-k">catch</span> <span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&amp;</span> <span class="tok-n">e</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Select failed: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+
+<span class="tok-c1">// Exception is thrown for query with incorrect return type</span>
+<span class="tok-n">try</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">&quot;123&quot;</span><span class="tok-p">);</span>
+<span class="tok-p">}</span>
+<span class="tok-k">catch</span> <span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_exception</span><span class="tok-o">&amp;</span> <span class="tok-n">e</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Select failed: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">e</span><span class="tok-p">.</span><span class="tok-n">what</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="xpath.w3c"><a class="anchor" href="#xpath.w3c"></a>8.6. Conformance to W3C specification</h3>
+<div class="paragraph">
+<p>Because of the differences in document object models, performance considerations and implementation complexity, pugixml does not provide a fully conformant XPath 1.0 implementation. This is the current list of incompatibilities:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Consecutive text nodes sharing the same parent are not merged, i.e. in <code>&lt;node&gt;text1 &lt;![CDATA[data]]&gt; text2&lt;/node&gt;</code> node should have one text node child, but instead has three.</p>
+</li>
+<li>
+<p>Since the document type declaration is not used for parsing, <code>id()</code> function always returns an empty node set.</p>
+</li>
+<li>
+<p>Namespace nodes are not supported (affects <code>namespace::</code> axis).</p>
+</li>
+<li>
+<p>Name tests are performed on QNames in XML document instead of expanded names; for <code>&lt;foo xmlns:ns1='uri' xmlns:ns2='uri'&gt;&lt;ns1:child/&gt;&lt;ns2:child/&gt;&lt;/foo&gt;</code>, query <code>foo/ns1:*</code> will return only the first child, not both of them. Compliant XPath implementations can return both nodes if the user provides appropriate namespace declarations.</p>
+</li>
+<li>
+<p>String functions consider a character to be either a single <code>char</code> value or a single <code>wchar_t</code> value, depending on the library configuration; this means that some string functions are not fully Unicode-aware. This affects <code>substring()</code>, <code>string-length()</code> and <code>translate()</code> functions.</p>
+</li>
+</ul>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="changes"><a class="anchor" href="#changes"></a>9. Changelog</h2>
+<div class="sectionbody">
+<div class="sect2">
+<h3 id="v1.6"><a class="anchor" href="#v1.6"></a>v1.6 <sup>10.04.2015</sup></h3>
+<div class="paragraph">
+<p>Maintenance release. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Specification changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Attribute/text values now use more digits when printing floating point numbers to guarantee round-tripping.</p>
+</li>
+<li>
+<p>Text nodes no longer get extra surrounding whitespace when pretty-printing nodes with mixed contents</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed translate and normalize-space XPath functions to no longer return internal NUL characters</p>
+</li>
+<li>
+<p>Fixed buffer overrun on malformed comments inside DOCTYPE sections</p>
+</li>
+<li>
+<p>DOCTYPE parsing can no longer run out of stack space on malformed inputs (XML parsing is now using bounded stack space)</p>
+</li>
+<li>
+<p>Adjusted processing instruction output to avoid malformed documents if the PI value contains <code>?&gt;</code></p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v1.5"><a class="anchor" href="#v1.5"></a>v1.5 <sup>27.11.2014</sup></h3>
+<div class="paragraph">
+<p>Major release, featuring a lot of performance improvements and some new features.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Specification changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p><code>xml_document::load(const char_t*)</code> was renamed to <code>load_string</code>; the old method is still available and will be deprecated in a future release</p>
+</li>
+<li>
+<p><code>xml_node::select_single_node</code> was renamed to <code>select_node</code>; the old method is still available and will be deprecated in a future release.</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added <code>xml_node::append_move</code> and other functions for moving nodes within a document</p>
+</li>
+<li>
+<p>Added <code>xpath_query::evaluate_node</code> for evaluating queries with a single node as a result</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Performance improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Optimized XML parsing (10-40% faster with clang/gcc, up to 10% faster with MSVC)</p>
+</li>
+<li>
+<p>Optimized memory consumption when copying nodes in the same document (string contents is now shared)</p>
+</li>
+<li>
+<p>Optimized node copying (10% faster for cross-document copies, 3x faster for inter-document copies; also it now consumes a constant amount of stack space)</p>
+</li>
+<li>
+<p>Optimized node output (60% faster; also it now consumes a constant amount of stack space)</p>
+</li>
+<li>
+<p>Optimized XPath allocation (query evaluation now results in fewer temporary allocations)</p>
+</li>
+<li>
+<p>Optimized XPath sorting (node set sorting is 2-3x faster in some cases)</p>
+</li>
+<li>
+<p>Optimized XPath evaluation (XPathMark suite is 100x faster; some commonly used queries are 3-4x faster)</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Compatibility improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed <code>xml_node::offset_debug</code> for corner cases</p>
+</li>
+<li>
+<p>Fixed undefined behavior while calling memcpy in some cases</p>
+</li>
+<li>
+<p>Fixed MSVC 2015 compilation warnings</p>
+</li>
+<li>
+<p>Fixed <code>contrib/foreach.hpp</code> for Boost 1.56.0</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Bug fixes</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Adjusted comment output to avoid malformed documents if the comment value contains <code>--</code></p>
+</li>
+<li>
+<p>Fix XPath sorting for documents that were constructed using append_buffer</p>
+</li>
+<li>
+<p>Fix <code>load_file</code> for wide-character paths with non-ASCII characters in MinGW with C&#43;&#43;11 mode enabled</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v1.4"><a class="anchor" href="#v1.4"></a>v1.4 <sup>27.02.2014</sup></h3>
+<div class="paragraph">
+<p>Major release, featuring various new features, bug fixes and compatibility improvements.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Specification changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Documents without element nodes are now rejected with <code>status_no_document_element</code> error, unless <code>parse_fragment</code> option is used</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added XML fragment parsing (<code>parse_fragment</code> flag)</p>
+</li>
+<li>
+<p>Added PCDATA whitespace trimming (<code>parse_trim_pcdata</code> flag)</p>
+</li>
+<li>
+<p>Added long long support for <code>xml_attribute</code> and <code>xml_text</code> (<code>as_llong</code>, <code>as_ullong</code> and <code>set_value</code>/<code>set</code> overloads)</p>
+</li>
+<li>
+<p>Added hexadecimal integer parsing support for <code>as_int</code>/<code>as_uint</code>/<code>as_llong</code>/<code>as_ullong</code></p>
+</li>
+<li>
+<p>Added <code>xml_node::append_buffer</code> to improve performance of assembling documents from fragments</p>
+</li>
+<li>
+<p><code>xml_named_node_iterator</code> is now bidirectional</p>
+</li>
+<li>
+<p>Reduced XPath stack consumption during compilation and evaluation (useful for embedded systems)</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Compatibility improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Improved support for platforms without wchar_t support</p>
+</li>
+<li>
+<p>Fixed several false positives in clang static analysis</p>
+</li>
+<li>
+<p>Fixed several compilation warnings for various GCC versions</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed undefined pointer arithmetic in XPath implementation</p>
+</li>
+<li>
+<p>Fixed non-seekable iostream support for certain stream types, i.e. Boost <code>file_source</code> with pipe input</p>
+</li>
+<li>
+<p>Fixed <code>xpath_query::return_type</code> for some expressions</p>
+</li>
+<li>
+<p>Fixed dllexport issues with <code>xml_named_node_iterator</code></p>
+</li>
+<li>
+<p>Fixed <code>find_child_by_attribute</code> assertion for attributes with null name/value</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v1.2"><a class="anchor" href="#v1.2"></a>v1.2 <sup>1.05.2012</sup></h3>
+<div class="paragraph">
+<p>Major release, featuring header-only mode, various interface enhancements (i.e. PCDATA manipulation and C&#43;&#43;11 iteration), many other features and compatibility improvements.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added <code>xml_text</code> helper class for working with PCDATA/CDATA contents of an element node</p>
+</li>
+<li>
+<p>Added optional header-only mode (controlled by <code>PUGIXML_HEADER_ONLY</code> define)</p>
+</li>
+<li>
+<p>Added <code>xml_node::children()</code> and <code>xml_node::attributes()</code> for C&#43;&#43;11 ranged for loop or <code>BOOST_FOREACH</code></p>
+</li>
+<li>
+<p>Added support for Latin-1 (ISO-8859-1) encoding conversion during loading and saving</p>
+</li>
+<li>
+<p>Added custom default values for <code>xml_attribute::as_*</code> (they are returned if the attribute does not exist)</p>
+</li>
+<li>
+<p>Added <code>parse_ws_pcdata_single</code> flag for preserving whitespace-only PCDATA in case it&#8217;s the only child</p>
+</li>
+<li>
+<p>Added <code>format_save_file_text</code> for <code>xml_document::save_file</code> to open files as text instead of binary (changes newlines on Windows)</p>
+</li>
+<li>
+<p>Added <code>format_no_escapes</code> flag to disable special symbol escaping (complements <code>~parse_escapes</code>)</p>
+</li>
+<li>
+<p>Added support for loading document from streams that do not support seeking</p>
+</li>
+<li>
+<p>Added <code>PUGIXML_MEMORY_*</code> constants for tweaking allocation behavior (useful for embedded systems)</p>
+</li>
+<li>
+<p>Added <code>PUGIXML_VERSION</code> preprocessor define</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Compatibility improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Parser does not require setjmp support (improves compatibility with some embedded platforms, enables <code>/clr:pure</code> compilation)</p>
+</li>
+<li>
+<p>STL forward declarations are no longer used (fixes SunCC/RWSTL compilation, fixes clang compilation in C&#43;&#43;11 mode)</p>
+</li>
+<li>
+<p>Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C&#43;&#43;/CLI compilation</p>
+</li>
+<li>
+<p>Fixed several compilation warnings for various GCC versions, Intel C&#43;&#43; compiler and Clang</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed unsafe bool conversion to avoid problems on C&#43;&#43;/CLI</p>
+</li>
+<li>
+<p>Iterator dereference operator is const now (fixes Boost <code>filter_iterator</code> support)</p>
+</li>
+<li>
+<p><code>xml_document::save_file</code> now checks for file I/O errors during saving</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v1.0"><a class="anchor" href="#v1.0"></a>v1.0 <sup>1.11.2010</sup></h3>
+<div class="paragraph">
+<p>Major release, featuring many XPath enhancements, wide character filename support, miscellaneous performance improvements, bug fixes and more.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>XPath:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>XPath implementation is moved to <code>pugixml.cpp</code> (which is the only source file now); use <code>PUGIXML_NO_XPATH</code> if you want to disable XPath to reduce code size</p>
+</li>
+<li>
+<p>XPath is now supported without exceptions (<code>PUGIXML_NO_EXCEPTIONS</code>); the error handling mechanism depends on the presence of exception support</p>
+</li>
+<li>
+<p>XPath is now supported without STL (<code>PUGIXML_NO_STL</code>)</p>
+</li>
+<li>
+<p>Introduced variable support</p>
+</li>
+<li>
+<p>Introduced new <code>xpath_query::evaluate_string</code>, which works without STL</p>
+</li>
+<li>
+<p>Introduced new <code>xpath_node_set</code> constructor (from an iterator range)</p>
+</li>
+<li>
+<p>Evaluation function now accept attribute context nodes</p>
+</li>
+<li>
+<p>All internal allocations use custom allocation functions</p>
+</li>
+<li>
+<p>Improved error reporting; now a last parsed offset is returned together with the parsing error</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed memory leak for loading from streams with stream exceptions turned on</p>
+</li>
+<li>
+<p>Fixed custom deallocation function calling with null pointer in one case</p>
+</li>
+<li>
+<p>Fixed missing attributes for iterator category functions; all functions/classes can now be DLL-exported</p>
+</li>
+<li>
+<p>Worked around Digital Mars compiler bug, which lead to minor read overfetches in several functions</p>
+</li>
+<li>
+<p><code>load_file</code> now works with 2+ Gb files in MSVC/MinGW</p>
+</li>
+<li>
+<p>XPath: fixed memory leaks for incorrect queries</p>
+</li>
+<li>
+<p>XPath: fixed <code>xpath_node()</code> attribute constructor with empty attribute argument</p>
+</li>
+<li>
+<p>XPath: fixed <code>lang()</code> function for non-ASCII arguments</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Specification changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>CDATA nodes containing <code>]]&gt;</code> are printed as several nodes; while this changes the internal structure, this is the only way to escape CDATA contents</p>
+</li>
+<li>
+<p>Memory allocation errors during parsing now preserve last parsed offset (to give an idea about parsing progress)</p>
+</li>
+<li>
+<p>If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children)</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Additional functionality:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added <code>xml_parse_result</code> default constructor</p>
+</li>
+<li>
+<p>Added <code>xml_document::load_file</code> and <code>xml_document::save_file</code> with wide character paths</p>
+</li>
+<li>
+<p>Added <code>as_utf8</code> and <code>as_wide</code> overloads for <code>std::wstring</code>/<code>std::string</code> arguments</p>
+</li>
+<li>
+<p>Added DOCTYPE node type (<code>node_doctype</code>) and a special parse flag, <code>parse_doctype</code>, to add such nodes to the document during parsing</p>
+</li>
+<li>
+<p>Added <code>parse_full</code> parse flag mask, which extends <code>parse_default</code> with all node type parsing flags except <code>parse_ws_pcdata</code></p>
+</li>
+<li>
+<p>Added <code>xml_node::hash_value()</code> and <code>xml_attribute::hash_value()</code> functions for use in hash-based containers</p>
+</li>
+<li>
+<p>Added <code>internal_object()</code> and additional constructor for both <code>xml_node</code> and <code>xml_attribute</code> for easier marshalling (useful for language bindings)</p>
+</li>
+<li>
+<p>Added <code>xml_document::document_element()</code> function</p>
+</li>
+<li>
+<p>Added <code>xml_node::prepend_attribute</code>, <code>xml_node::prepend_child</code> and <code>xml_node::prepend_copy</code> functions</p>
+</li>
+<li>
+<p>Added <code>xml_node::append_child</code>, <code>xml_node::prepend_child</code>, <code>xml_node::insert_child_before</code> and <code>xml_node::insert_child_after</code> overloads for element nodes (with name instead of type)</p>
+</li>
+<li>
+<p>Added <code>xml_document::reset()</code> function</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Performance improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p><code>xml_node::root()</code> and <code>xml_node::offset_debug()</code> are now O(1) instead of O(logN)</p>
+</li>
+<li>
+<p>Minor parsing optimizations</p>
+</li>
+<li>
+<p>Minor memory optimization for strings in DOM tree (<code>set_name</code>/<code>set_value</code>)</p>
+</li>
+<li>
+<p>Memory optimization for string memory reclaiming in DOM tree (<code>set_name</code>/<code>set_value</code> now reallocate the buffer if memory waste is too big)</p>
+</li>
+<li>
+<p>XPath: optimized document order sorting</p>
+</li>
+<li>
+<p>XPath: optimized child/attribute axis step</p>
+</li>
+<li>
+<p>XPath: optimized number-to-string conversions in MSVC</p>
+</li>
+<li>
+<p>XPath: optimized concat for many arguments</p>
+</li>
+<li>
+<p>XPath: optimized evaluation allocation mechanism: constant and document strings are not heap-allocated</p>
+</li>
+<li>
+<p>XPath: optimized evaluation allocation mechanism: all temporaries' allocations use fast stack-like allocator</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Compatibility:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Removed wildcard functions (<code>xml_node::child_w</code>, <code>xml_node::attribute_w</code>, etc.)</p>
+</li>
+<li>
+<p>Removed <code>xml_node::all_elements_by_name</code></p>
+</li>
+<li>
+<p>Removed <code>xpath_type_t</code> enumeration; use <code>xpath_value_type</code> instead</p>
+</li>
+<li>
+<p>Removed <code>format_write_bom_utf8</code> enumeration; use <code>format_write_bom</code> instead</p>
+</li>
+<li>
+<p>Removed <code>xml_document::precompute_document_order</code>, <code>xml_attribute::document_order</code> and <code>xml_node::document_order</code> functions; document order sort optimization is now automatic</p>
+</li>
+<li>
+<p>Removed <code>xml_document::parse</code> functions and <code>transfer_ownership</code> struct; use <code>xml_document::load_buffer_inplace</code> and <code>xml_document::load_buffer_inplace_own</code> instead</p>
+</li>
+<li>
+<p>Removed <code>as_utf16</code> function; use <code>as_wide</code> instead</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.9"><a class="anchor" href="#v0.9"></a>v0.9 <sup>1.07.2010</sup></h3>
+<div class="paragraph">
+<p>Major release, featuring extended and improved Unicode support, miscellaneous performance improvements, bug fixes and more.</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Major Unicode improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Introduced encoding support (automatic/manual encoding detection on load, manual encoding selection on save, conversion from/to UTF8, UTF16 LE/BE, UTF32 LE/BE)</p>
+</li>
+<li>
+<p>Introduced <code>wchar_t</code> mode (you can set <code>PUGIXML_WCHAR_MODE</code> define to switch pugixml internal encoding from UTF8 to <code>wchar_t</code>; all functions are switched to their Unicode variants)</p>
+</li>
+<li>
+<p>Load/save functions now support wide streams</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed document corruption on failed parsing bug</p>
+</li>
+<li>
+<p>XPath string/number conversion improvements (increased precision, fixed crash for huge numbers)</p>
+</li>
+<li>
+<p>Improved DOCTYPE parsing: now parser recognizes all well-formed DOCTYPE declarations</p>
+</li>
+<li>
+<p>Fixed <code>xml_attribute::as_uint()</code> for large numbers (i.e. 2<sup>32</sup>-1)</p>
+</li>
+<li>
+<p>Fixed <code>xml_node::first_element_by_path</code> for path components that are prefixes of node names, but are not exactly equal to them.</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Specification changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p><code>parse()</code> API changed to <code>load_buffer</code>/<code>load_buffer_inplace</code>/<code>load_buffer_inplace_own</code>; <code>load_buffer</code> APIs do not require zero-terminated strings.</p>
+</li>
+<li>
+<p>Renamed <code>as_utf16</code> to <code>as_wide</code></p>
+</li>
+<li>
+<p>Changed <code>xml_node::offset_debug</code> return type and <code>xml_parse_result::offset</code> type to <code>ptrdiff_t</code></p>
+</li>
+<li>
+<p>Nodes/attributes with empty names are now printed as <code>:anonymous</code></p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Performance improvements:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Optimized document parsing and saving</p>
+</li>
+<li>
+<p>Changed internal memory management: internal allocator is used for both metadata and name/value data; allocated pages are deleted if all allocations from them are deleted</p>
+</li>
+<li>
+<p>Optimized memory consumption: <code>sizeof(xml_node_struct)</code> reduced from 40 bytes to 32 bytes on x86</p>
+</li>
+<li>
+<p>Optimized debug mode parsing/saving by order of magnitude</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Miscellaneous:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>All STL includes except <code>&lt;exception&gt;</code> in <code>pugixml.hpp</code> are replaced with forward declarations</p>
+</li>
+<li>
+<p><code>xml_node::remove_child</code> and <code>xml_node::remove_attribute</code> now return the operation result</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Compatibility:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p><code>parse()</code> and <code>as_utf16</code> are left for compatibility (these functions are deprecated and will be removed in version 1.0)</p>
+</li>
+<li>
+<p>Wildcard functions, <code>document_order</code>/<code>precompute_document_order</code> functions, <code>all_elements_by_name</code> function and <code>format_write_bom_utf8</code> flag are deprecated and will be removed in version 1.0</p>
+</li>
+<li>
+<p><code>xpath_type_t</code> enumeration was renamed to <code>xpath_value_type</code>; <code>xpath_type_t</code> is deprecated and will be removed in version 1.0</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.5"><a class="anchor" href="#v0.5"></a>v0.5 <sup>8.11.2009</sup></h3>
+<div class="paragraph">
+<p>Major bugfix release. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>XPath bugfixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed <code>translate()</code>, <code>lang()</code> and <code>concat()</code> functions (infinite loops/crashes)</p>
+</li>
+<li>
+<p>Fixed compilation of queries with empty literal strings (<code>""</code>)</p>
+</li>
+<li>
+<p>Fixed axis tests: they never add empty nodes/attributes to the resulting node set now</p>
+</li>
+<li>
+<p>Fixed string-value evaluation for node-set (the result excluded some text descendants)</p>
+</li>
+<li>
+<p>Fixed <code>self::</code> axis (it behaved like <code>ancestor-or-self::</code>)</p>
+</li>
+<li>
+<p>Fixed <code>following::</code> and <code>preceding::</code> axes (they included descendent and ancestor nodes, respectively)</p>
+</li>
+<li>
+<p>Minor fix for <code>namespace-uri()</code> function (namespace declaration scope includes the parent element of namespace declaration attribute)</p>
+</li>
+<li>
+<p>Some incorrect queries are no longer parsed now (i.e. <code>foo: *</code>)</p>
+</li>
+<li>
+<p>Fixed <code>text()</code>/etc. node test parsing bug (i.e. <code>foo[text()]</code> failed to compile)</p>
+</li>
+<li>
+<p>Fixed root step (<code>/</code>) - it now selects empty node set if query is evaluated on empty node</p>
+</li>
+<li>
+<p>Fixed string to number conversion (<code>"123 "</code> converted to NaN, <code>"123 .456"</code> converted to 123.456 - now the results are 123 and NaN, respectively)</p>
+</li>
+<li>
+<p>Node set copying now preserves sorted type; leads to better performance on some queries</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Miscellaneous bugfixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed <code>xml_node::offset_debug</code> for PI nodes</p>
+</li>
+<li>
+<p>Added empty attribute checks to <code>xml_node::remove_attribute</code></p>
+</li>
+<li>
+<p>Fixed <code>node_pi</code> and <code>node_declaration</code> copying</p>
+</li>
+<li>
+<p>Const-correctness fixes</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Specification changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p><code>xpath_node::select_nodes()</code> and related functions now throw exception if expression return type is not node set (instead of assertion)</p>
+</li>
+<li>
+<p><code>xml_node::traverse()</code> now sets depth to -1 for both <code>begin()</code> and <code>end()</code> callbacks (was 0 at <code>begin()</code> and -1 at <code>end()</code>)</p>
+</li>
+<li>
+<p>In case of non-raw node printing a newline is output after PCDATA inside nodes if the PCDATA has siblings</p>
+</li>
+<li>
+<p>UTF8 &#8594; <code>wchar_t</code> conversion now considers 5-byte UTF8-like sequences as invalid</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added <code>xpath_node_set::operator[]</code> for index-based iteration</p>
+</li>
+<li>
+<p>Added <code>xpath_query::return_type()</code></p>
+</li>
+<li>
+<p>Added getter accessors for memory-management functions</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.42"><a class="anchor" href="#v0.42"></a>v0.42 <sup>17.09.2009</sup></h3>
+<div class="paragraph">
+<p>Maintenance release. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed deallocation in case of custom allocation functions or if <code>delete[]</code> / <code>free</code> are incompatible</p>
+</li>
+<li>
+<p>XPath parser fixed for incorrect queries (i.e. incorrect XPath queries should now always fail to compile)</p>
+</li>
+<li>
+<p>Const-correctness fixes for <code>find_child_by_attribute</code></p>
+</li>
+<li>
+<p>Improved compatibility (miscellaneous warning fixes, fixed <code>&lt;cstring&gt;</code> include dependency for GCC)</p>
+</li>
+<li>
+<p>Fixed iterator begin/end and print function to work correctly for empty nodes</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added <code>PUGIXML_API</code>/<code>PUGIXML_CLASS</code>/<code>PUGIXML_FUNCTION</code> configuration macros to control class/function attributes</p>
+</li>
+<li>
+<p>Added <code>xml_attribute::set_value</code> overloads for different types</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.41"><a class="anchor" href="#v0.41"></a>v0.41 <sup>8.02.2009</sup></h3>
+<div class="paragraph">
+<p>Maintenance release. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed bug with node printing (occasionally some content was not written to output stream)</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.4"><a class="anchor" href="#v0.4"></a>v0.4 <sup>18.01.2009</sup></h3>
+<div class="paragraph">
+<p>Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Documentation fix in samples for <code>parse()</code> with manual lifetime control</p>
+</li>
+<li>
+<p>Fixed document order sorting in XPath (it caused wrong order of nodes after <code>xpath_node_set::sort</code> and wrong results of some XPath queries)</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Node printing changes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Single quotes are no longer escaped when printing nodes</p>
+</li>
+<li>
+<p>Symbols in second half of ASCII table are no longer escaped when printing nodes; because of this, <code>format_utf8</code> flag is deleted as it&#8217;s no longer needed and <code>format_write_bom</code> is renamed to <code>format_write_bom_utf8</code>.</p>
+</li>
+<li>
+<p>Reworked node printing - now it works via <code>xml_writer</code> interface; implementations for <code>FILE*</code> and <code>std::ostream</code> are available. As a side-effect, <code>xml_document::save_file</code> now works without STL.</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added unsigned integer support for attributes (<code>xml_attribute::as_uint</code>, <code>xml_attribute::operator=</code>)</p>
+</li>
+<li>
+<p>Now document declaration (<code>&lt;?xml &#8230;&#8203;?&gt;</code>) is parsed as node with type <code>node_declaration</code> when <code>parse_declaration</code> flag is specified (access to encoding/version is performed as if they were attributes, i.e. <code>doc.child("xml").attribute("version").as_float()</code>); corresponding flags for node printing were also added</p>
+</li>
+<li>
+<p>Added support for custom memory management (see <code>set_memory_management_functions</code> for details)</p>
+</li>
+<li>
+<p>Implemented node/attribute copying (see <code>xml_node::insert_copy_*</code> and <code>xml_node::append_copy</code> for details)</p>
+</li>
+<li>
+<p>Added <code>find_child_by_attribute</code> and <code>find_child_by_attribute_w</code> to simplify parsing code in some cases (i.e. COLLADA files)</p>
+</li>
+<li>
+<p>Added file offset information querying for debugging purposes (now you&#8217;re able to determine exact location of any <code>xml_node</code> in parsed file, see <code>xml_node::offset_debug</code> for details)</p>
+</li>
+<li>
+<p>Improved error handling for parsing - now <code>load()</code>, <code>load_file()</code> and <code>parse()</code> return <code>xml_parse_result</code>, which contains error code and last parsed offset; this does not break old interface as <code>xml_parse_result</code> can be implicitly casted to <code>bool</code>.</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.34"><a class="anchor" href="#v0.34"></a>v0.34 <sup>31.10.2007</sup></h3>
+<div class="paragraph">
+<p>Maintenance release. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed bug with loading from text-mode iostreams</p>
+</li>
+<li>
+<p>Fixed leak when <code>transfer_ownership</code> is true and parsing is failing</p>
+</li>
+<li>
+<p>Fixed bug in saving (<code>\r</code> and <code>\n</code> are now escaped in attribute values)</p>
+</li>
+<li>
+<p>Renamed <code>free()</code> to <code>destroy()</code> - some macro conflicts were reported</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Improved compatibility (supported Digital Mars C&#43;&#43;, MSVC 6, CodeWarrior 8, PGI C&#43;&#43;, Comeau, supported PS3 and XBox360)</p>
+</li>
+<li>
+<p><code>PUGIXML_NO_EXCEPTION</code> flag for platforms without exception handling</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.3"><a class="anchor" href="#v0.3"></a>v0.3 <sup>21.02.2007</sup></h3>
+<div class="paragraph">
+<p>Refactored, reworked and improved version. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Interface:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Added XPath</p>
+</li>
+<li>
+<p>Added tree modification functions</p>
+</li>
+<li>
+<p>Added no STL compilation mode</p>
+</li>
+<li>
+<p>Added saving document to file</p>
+</li>
+<li>
+<p>Refactored parsing flags</p>
+</li>
+<li>
+<p>Removed <code>xml_parser</code> class in favor of <code>xml_document</code></p>
+</li>
+<li>
+<p>Added transfer ownership parsing mode</p>
+</li>
+<li>
+<p>Modified the way <code>xml_tree_walker</code> works</p>
+</li>
+<li>
+<p>Iterators are now non-constant</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>Implementation:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Support of several compilers and platforms</p>
+</li>
+<li>
+<p>Refactored and sped up parsing core</p>
+</li>
+<li>
+<p>Improved standard compliancy</p>
+</li>
+<li>
+<p>Added XPath implementation</p>
+</li>
+<li>
+<p>Fixed several bugs</p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.2"><a class="anchor" href="#v0.2"></a>v0.2 <sup>6.11.2006</sup></h3>
+<div class="paragraph">
+<p>First public release. Changes:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Bug fixes:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Fixed <code>child_value()</code> (for empty nodes)</p>
+</li>
+<li>
+<p>Fixed <code>xml_parser_impl</code> warning at W4</p>
+</li>
+</ol>
+</div>
+</li>
+<li>
+<p>New features:</p>
+<div class="olist arabic">
+<ol class="arabic">
+<li>
+<p>Introduced <code>child_value(name)</code> and <code>child_value_w(name)</code></p>
+</li>
+<li>
+<p><code>parse_eol_pcdata</code> and <code>parse_eol_attribute</code> flags + <code>parse_minimal</code> optimizations</p>
+</li>
+<li>
+<p>Optimizations of <code>strconv_t</code></p>
+</li>
+</ol>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
+<h3 id="v0.1"><a class="anchor" href="#v0.1"></a>v0.1 <sup>15.07.2006</sup></h3>
+<div class="paragraph">
+<p>First private release for testing purposes</p>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="apiref"><a class="anchor" href="#apiref"></a>10. API Reference</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>This is the reference for all macros, types, enumerations, classes and functions in pugixml. Each symbol is a link that leads to the relevant section of the manual.</p>
+</div>
+<div class="sect2">
+<h3 id="apiref.macros"><a class="anchor" href="#apiref.macros"></a>10.1. Macros</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-cp">#define <a href="#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_NO_XPATH">PUGIXML_NO_XPATH</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_NO_STL">PUGIXML_NO_STL</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_API">PUGIXML_API</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_CLASS">PUGIXML_CLASS</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_FUNCTION">PUGIXML_FUNCTION</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_MEMORY_PAGE_SIZE">PUGIXML_MEMORY_PAGE_SIZE</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_MEMORY_OUTPUT_STACK">PUGIXML_MEMORY_OUTPUT_STACK</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_MEMORY_XPATH_PAGE_SIZE">PUGIXML_MEMORY_XPATH_PAGE_SIZE</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_HEADER_ONLY">PUGIXML_HEADER_ONLY</a></span>
+<span class="tok-cp">#define <a href="#PUGIXML_HAS_LONG_LONG">PUGIXML_HAS_LONG_LONG</a></span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="apiref.types"><a class="anchor" href="#apiref.types"></a>10.2. Types</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">typedef</span> <span class="tok-n">configuration</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span> <a href="#char_t">char_t</a><span class="tok-p">;</span>
+<span class="tok-k">typedef</span> <span class="tok-n">configuration</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span> <a href="#string_t">string_t</a><span class="tok-p">;</span>
+<span class="tok-k">typedef</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-p">(</span><span class="tok-o">*</span><a href="#allocation_function">allocation_function</a><span class="tok-p">)(</span><span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+<span class="tok-k">typedef</span> <span class="tok-nf">void</span> <span class="tok-p">(</span><span class="tok-o">*</span><a href="#deallocation_function">deallocation_function</a><span class="tok-p">)(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">ptr</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="apiref.enums"><a class="anchor" href="#apiref.enums"></a>10.3. Enumerations</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">enum</span> <a href="#xml_node_type">xml_node_type</a>
+ <a href="#node_null">node_null</a>
+ <a href="#node_document">node_document</a>
+ <a href="#node_element">node_element</a>
+ <a href="#node_pcdata">node_pcdata</a>
+ <a href="#node_cdata">node_cdata</a>
+ <a href="#node_comment">node_comment</a>
+ <a href="#node_pi">node_pi</a>
+ <a href="#node_declaration">node_declaration</a>
+ <a href="#node_doctype">node_doctype</a>
+
+<span class="tok-k">enum</span> <a href="#xml_parse_status">xml_parse_status</a>
+ <a href="#status_ok">status_ok</a>
+ <a href="#status_file_not_found">status_file_not_found</a>
+ <a href="#status_io_error">status_io_error</a>
+ <a href="#status_out_of_memory">status_out_of_memory</a>
+ <a href="#status_internal_error">status_internal_error</a>
+ <a href="#status_unrecognized_tag">status_unrecognized_tag</a>
+ <a href="#status_bad_pi">status_bad_pi</a>
+ <a href="#status_bad_comment">status_bad_comment</a>
+ <a href="#status_bad_cdata">status_bad_cdata</a>
+ <a href="#status_bad_doctype">status_bad_doctype</a>
+ <a href="#status_bad_pcdata">status_bad_pcdata</a>
+ <a href="#status_bad_start_element">status_bad_start_element</a>
+ <a href="#status_bad_attribute">status_bad_attribute</a>
+ <a href="#status_bad_end_element">status_bad_end_element</a>
+ <a href="#status_end_element_mismatch">status_end_element_mismatch</a>
+ <a href="#status_append_invalid_root">status_append_invalid_root</a>
+ <a href="#status_no_document_element">status_no_document_element</a>
+
+<span class="tok-k">enum</span> <a href="#xml_encoding">xml_encoding</a>
+ <a href="#encoding_auto">encoding_auto</a>
+ <a href="#encoding_utf8">encoding_utf8</a>
+ <a href="#encoding_utf16_le">encoding_utf16_le</a>
+ <a href="#encoding_utf16_be">encoding_utf16_be</a>
+ <a href="#encoding_utf16">encoding_utf16</a>
+ <a href="#encoding_utf32_le">encoding_utf32_le</a>
+ <a href="#encoding_utf32_be">encoding_utf32_be</a>
+ <a href="#encoding_utf32">encoding_utf32</a>
+ <a href="#encoding_wchar">encoding_wchar</a>
+ <a href="#encoding_latin1">encoding_latin1</a>
+
+<span class="tok-k">enum</span> <a href="#xpath_value_type">xpath_value_type</a>
+ <a href="#xpath_type_none">xpath_type_none</a>
+ <a href="#xpath_type_node_set">xpath_type_node_set</a>
+ <a href="#xpath_type_number">xpath_type_number</a>
+ <a href="#xpath_type_string">xpath_type_string</a>
+ <a href="#xpath_type_boolean">xpath_type_boolean</a></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="apiref.constants"><a class="anchor" href="#apiref.constants"></a>10.4. Constants</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// Formatting options bit flags:</span>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_default">format_default</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_indent">format_indent</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_no_declaration">format_no_declaration</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_no_escapes">format_no_escapes</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_raw">format_raw</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_save_file_text">format_save_file_text</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#format_write_bom">format_write_bom</a>
+
+<span class="tok-c1">// Parsing options bit flags:</span>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_cdata">parse_cdata</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_comments">parse_comments</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_declaration">parse_declaration</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_default">parse_default</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_doctype">parse_doctype</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_eol">parse_eol</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_escapes">parse_escapes</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_fragment">parse_fragment</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_full">parse_full</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_minimal">parse_minimal</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_pi">parse_pi</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_trim_pcdata">parse_trim_pcdata</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_ws_pcdata">parse_ws_pcdata</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_wconv_attribute">parse_wconv_attribute</a>
+<span class="tok-k">const</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#parse_wnorm_attribute">parse_wnorm_attribute</a></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="apiref.classes"><a class="anchor" href="#apiref.classes"></a>10.5. Classes</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">class</span> <a href="#xml_attribute">xml_attribute</a>
+ <a href="#xml_attribute::ctor">xml_attribute</a><span class="tok-p">();</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::empty">empty</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">operator</span> <a href="#xml_attribute::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::comparison">operator&lt;</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::comparison">operator&gt;</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::comparison">operator&lt;=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::comparison">operator&gt;=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">size_t</span> <a href="#xml_attribute::hash_value">hash_value</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xml_attribute</span> <a href="#xml_attribute::next_attribute">next_attribute</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_attribute::previous_attribute">previous_attribute</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_attribute::name">name</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_attribute::value">value</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_attribute::as_string">as_string</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">int</span> <a href="#xml_attribute::as_int">as_int</a><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#xml_attribute::as_uint">as_uint</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">double</span> <a href="#xml_attribute::as_double">as_double</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">float</span> <a href="#xml_attribute::as_float">as_float</a><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::as_bool">as_bool</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-nb">false</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">long</span> <span class="tok-kt">long</span> <a href="#xml_attribute::as_llong">as_llong</a><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <a href="#xml_attribute::as_ullong">as_ullong</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_name">set_name</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_attribute::set_value">set_value</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <a href="#xml_attribute::assign">operator=</a><span class="tok-p">(</span><span class="tok-n">unsnigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+
+<span class="tok-k">class</span> <a href="#xml_node">xml_node</a>
+ <a href="#xml_node::ctor">xml_node</a><span class="tok-p">();</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_node::empty">empty</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">operator</span> <a href="#xml_node::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_node::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::comparison">operator&lt;</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::comparison">operator&gt;</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::comparison">operator&lt;=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::comparison">operator&gt;=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">r</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">size_t</span> <a href="#xml_node::hash_value">hash_value</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xml_node_type</span> <a href="#xml_node::type">type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_node::name">name</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_node::value">value</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_node::parent">parent</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::first_child">first_child</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::last_child">last_child</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::next_sibling">next_sibling</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::previous_sibling">previous_sibling</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::first_attribute">first_attribute</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::last_attribute">last_attribute</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span> <a href="#xml_node::children">children</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span> <a href="#xml_node::children">children</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">implementation</span><span class="tok-o">-</span><span class="tok-n">defined</span><span class="tok-o">-</span><span class="tok-n">type</span> <a href="#xml_node::attributes">attributes</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_node::child">child</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::attribute">attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::next_sibling_name">next_sibling</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::previous_sibling_name">previous_sibling</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_value</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">attr_value</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_node::child_value">child_value</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_node::child_value">child_value</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_text</span> <a href="#xml_node::text">text</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">typedef</span> <span class="tok-n">xml_node_iterator</span> <a href="#xml_node_iterator">iterator</a><span class="tok-p">;</span>
+ <span class="tok-n">iterator</span> <a href="#xml_node::begin">begin</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">iterator</span> <a href="#xml_node::end">end</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">typedef</span> <span class="tok-n">xml_attribute_iterator</span> <a href="#xml_attribute_iterator">attribute_iterator</a><span class="tok-p">;</span>
+ <span class="tok-n">attribute_iterator</span> <a href="#xml_node::attributes_begin">attributes_begin</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">attribute_iterator</span> <a href="#xml_node::attributes_end">attributes_end</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_node::traverse">traverse</a><span class="tok-p">(</span><span class="tok-n">xml_tree_walker</span><span class="tok-o">&amp;</span> <span class="tok-n">walker</span><span class="tok-p">);</span>
+
+ <span class="tok-k">template</span> <span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-n">Predicate</span><span class="tok-o">&gt;</span> <span class="tok-n">xml_attribute</span> <a href="#xml_node::find_attribute">find_attribute</a><span class="tok-p">(</span><span class="tok-n">Predicate</span> <span class="tok-n">pred</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">template</span> <span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-n">Predicate</span><span class="tok-o">&gt;</span> <span class="tok-n">xml_node</span> <a href="#xml_node::find_child">find_child</a><span class="tok-p">(</span><span class="tok-n">Predicate</span> <span class="tok-n">pred</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">template</span> <span class="tok-o">&lt;</span><span class="tok-k">typename</span> <span class="tok-n">Predicate</span><span class="tok-o">&gt;</span> <span class="tok-n">xml_node</span> <a href="#xml_node::find_node">find_node</a><span class="tok-p">(</span><span class="tok-n">Predicate</span> <span class="tok-n">pred</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">string_t</span> <a href="#xml_node::path">path</a><span class="tok-p">(</span><span class="tok-kt">char_t</span> <span class="tok-n">delimiter</span> <span class="tok-o">=</span> <span class="tok-sc">&#39;/&#39;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::first_element_by_path">xml_node::first_element_by_path</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-kt">char_t</span> <span class="tok-n">delimiter</span> <span class="tok-o">=</span> <span class="tok-sc">&#39;/&#39;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::root">root</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">ptrdiff_t</span> <a href="#xml_node::offset_debug">offset_debug</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_node::set_name">set_name</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::set_value">set_value</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::append_attribute">append_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::prepend_attribute">prepend_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::insert_attribute_after">insert_attribute_after</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::insert_attribute_before">insert_attribute_before</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_node::append_child">append_child</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span> <span class="tok-o">=</span> <span class="tok-n">node_element</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::prepend_child">prepend_child</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span> <span class="tok-o">=</span> <span class="tok-n">node_element</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_child_after">insert_child_after</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_child_before">insert_child_before</a><span class="tok-p">(</span><span class="tok-n">xml_node_type</span> <span class="tok-n">type</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_node::append_child">append_child</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::prepend_child">prepend_child</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_child_after">insert_child_after</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_child_before">insert_child_before</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::append_copy">append_copy</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::prepend_copy">prepend_copy</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::insert_copy_after">insert_copy_after</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xml_node::insert_copy_before">insert_copy_before</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attr</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_node::append_copy">append_copy</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::prepend_copy">prepend_copy</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_copy_after">insert_copy_after</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_copy_before">insert_copy_before</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_node::append_move">append_move</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::prepend_move">prepend_move</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_move_after">insert_move_after</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_node</span> <a href="#xml_node::insert_move_before">insert_move_before</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">moved</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_node::remove_attribute">remove_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">a</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::remove_attribute">remove_attribute</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::remove_child">remove_child</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_node::remove_child">remove_child</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_node::append_buffer">append_buffer</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">void</span> <a href="#xml_node::print">print</a><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&amp;</span> <span class="tok-n">writer</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">depth</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">void</span> <a href="#xml_node::print_stream">print</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&amp;</span> <span class="tok-n">os</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">depth</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">void</span> <a href="#xml_node::print_stream">print</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&amp;</span> <span class="tok-n">os</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">depth</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xpath_node</span> <a href="#xml_node::select_node">select_node</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xpath_node</span> <a href="#xml_node::select_node_precomp">select_node</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_query</span><span class="tok-o">&amp;</span> <span class="tok-n">query</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xpath_node_set</span> <a href="#xml_node::select_nodes">select_nodes</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xpath_node_set</span> <a href="#xml_node::select_nodes_precomp">select_nodes</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_query</span><span class="tok-o">&amp;</span> <span class="tok-n">query</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xml_document">xml_document</a>
+ <a href="#xml_document::ctor">xml_document</a><span class="tok-p">();</span>
+ <span class="tok-o">~</span><a href="#xml_document::dtor">xml_document</a><span class="tok-p">();</span>
+
+ <span class="tok-kt">void</span> <a href="#xml_document::reset">reset</a><span class="tok-p">();</span>
+ <span class="tok-kt">void</span> <a href="#xml_document::reset">reset</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_document</span><span class="tok-o">&amp;</span> <span class="tok-n">proto</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_stream">load</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">istream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_stream">load</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wistream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_string">load_string</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_file">load_file</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_file_wide">load_file</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_buffer">load_buffer</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_buffer_inplace">load_buffer_inplace</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_parse_result</span> <a href="#xml_document::load_buffer_inplace_own">load_buffer_inplace_own</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">contents</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">options</span> <span class="tok-o">=</span> <span class="tok-n">parse_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_document::save_file">save_file</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_document::save_file_wide">save_file</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">path</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">void</span> <a href="#xml_document::save_stream">save</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">void</span> <a href="#xml_document::save_stream">save</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">void</span> <a href="#xml_document::save">save</a><span class="tok-p">(</span><span class="tok-n">xml_writer</span><span class="tok-o">&amp;</span> <span class="tok-n">writer</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">indent</span> <span class="tok-o">=</span> <span class="tok-s">&quot;</span><span class="tok-se">\t</span><span class="tok-s">&quot;</span><span class="tok-p">,</span> <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">flags</span> <span class="tok-o">=</span> <span class="tok-n">format_default</span><span class="tok-p">,</span> <span class="tok-n">xml_encoding</span> <span class="tok-n">encoding</span> <span class="tok-o">=</span> <span class="tok-n">encoding_auto</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_document::document_element">document_element</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">struct</span> <a href="#xml_parse_result">xml_parse_result</a>
+ <span class="tok-n">xml_parse_status</span> <a href="#xml_parse_result::status">status</a><span class="tok-p">;</span>
+ <span class="tok-kt">ptrdiff_t</span> <a href="#xml_parse_result::offset">offset</a><span class="tok-p">;</span>
+ <span class="tok-n">xml_encoding</span> <a href="#xml_parse_result::encoding">encoding</a><span class="tok-p">;</span>
+
+ <span class="tok-k">operator</span> <a href="#xml_parse_result::bool">bool</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <a href="#xml_parse_result::description">description</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xml_node_iterator">xml_node_iterator</a>
+<span class="tok-k">class</span> <a href="#xml_attribute_iterator">xml_attribute_iterator</a>
+
+<span class="tok-k">class</span> <a href="#xml_tree_walker">xml_tree_walker</a>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <a href="#xml_tree_walker::begin">begin</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <a href="#xml_tree_walker::for_each">for_each</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">;</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <a href="#xml_tree_walker::end">end</a><span class="tok-p">(</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">int</span> <a href="#xml_tree_walker::depth">depth</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xml_text">xml_text</a>
+ <span class="tok-kt">bool</span> <a href="#xml_text::empty">empty</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">operator</span> <a href="#xml_text::unspecified_bool_type">xml_text::unspecified_bool_type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_text::get">xml_text::get</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xml_text::as_string">as_string</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&quot;</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">int</span> <a href="#xml_text::as_int">as_int</a><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <a href="#xml_text::as_uint">as_uint</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">double</span> <a href="#xml_text::as_double">as_double</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">float</span> <a href="#xml_text::as_float">as_float</a><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::as_bool">as_bool</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-nb">false</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">long</span> <span class="tok-kt">long</span> <a href="#xml_text::as_llong">as_llong</a><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <a href="#xml_text::as_ullong">as_ullong</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">def</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xml_text::set">set</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">int</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">float</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+ <span class="tok-n">xml_text</span><span class="tok-o">&amp;</span> <a href="#xml_text::assign">operator=</a><span class="tok-p">(</span><span class="tok-kt">unsigned</span> <span class="tok-kt">long</span> <span class="tok-kt">long</span> <span class="tok-n">rhs</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xml_text::data">data</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xml_writer">xml_writer</a>
+ <span class="tok-k">virtual</span> <span class="tok-kt">void</span> <a href="#xml_writer::write">write</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xml_writer_file">xml_writer_file</a><span class="tok-o">:</span> <span class="tok-k">public</span> <span class="tok-n">xml_writer</span>
+ <a href="#xml_writer_file">xml_writer_file</a><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">file</span><span class="tok-p">);</span>
+
+<span class="tok-k">class</span> <a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-o">:</span> <span class="tok-k">public</span> <span class="tok-n">xml_writer</span>
+ <a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ostream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">);</span>
+ <a href="#xml_writer_stream">xml_writer_stream</a><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wostream</span><span class="tok-o">&amp;</span> <span class="tok-n">stream</span><span class="tok-p">);</span>
+
+<span class="tok-k">struct</span> <a href="#xpath_parse_result">xpath_parse_result</a>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <a href="#xpath_parse_result::error">error</a><span class="tok-p">;</span>
+ <span class="tok-kt">ptrdiff_t</span> <a href="#xpath_parse_result::offset">offset</a><span class="tok-p">;</span>
+
+ <span class="tok-k">operator</span> <a href="#xpath_parse_result::bool">bool</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <a href="#xpath_parse_result::description">description</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xpath_query">xpath_query</a>
+ <span class="tok-k">explicit</span> <a href="#xpath_query::ctor">xpath_query</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">query</span><span class="tok-p">,</span> <span class="tok-n">xpath_variable_set</span><span class="tok-o">*</span> <span class="tok-n">variables</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">bool</span> <a href="#xpath_query::evaluate_boolean">evaluate_boolean</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">double</span> <a href="#xpath_query::evaluate_number">evaluate_number</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">string_t</span> <a href="#xpath_query::evaluate_string">evaluate_string</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">size_t</span> <a href="#xpath_query::evaluate_string_buffer">evaluate_string</a><span class="tok-p">(</span><span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">capacity</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xpath_node_set</span> <a href="#xpath_query::evaluate_node_set">evaluate_node_set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xpath_node</span> <a href="#xpath_query::evaluate_node">evaluate_node</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xpath_value_type</span> <a href="#xpath_query::return_type">return_type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-n">xpath_parse_result</span><span class="tok-o">&amp;</span> <a href="#xpath_query::result">result</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">operator</span> <a href="#xpath_query::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xpath_exception">xpath_exception</a><span class="tok-o">:</span> <span class="tok-k">public</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">exception</span>
+ <span class="tok-k">virtual</span> <span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <a href="#xpath_exception::what">what</a><span class="tok-p">()</span> <span class="tok-k">const</span> <span class="tok-k">throw</span><span class="tok-p">();</span>
+
+ <span class="tok-k">const</span> <span class="tok-n">xpath_parse_result</span><span class="tok-o">&amp;</span> <a href="#xpath_exception::result">result</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xpath_node">xpath_node</a>
+ <a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">();</span>
+ <a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">);</span>
+ <a href="#xpath_node::ctor">xpath_node</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xml_attribute</span><span class="tok-o">&amp;</span> <span class="tok-n">attribute</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">parent</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xml_node</span> <a href="#xpath_node::node">node</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_attribute</span> <a href="#xpath_node::attribute">attribute</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xml_node</span> <a href="#xpath_node::parent">parent</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">operator</span> <a href="#xpath_node::unspecified_bool_type">unspecified_bool_type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_node::comparison">operator==</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_node::comparison">operator!=</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <span class="tok-n">n</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+<span class="tok-k">class</span> <a href="#xpath_node_set">xpath_node_set</a>
+ <a href="#xpath_node_set::ctor">xpath_node_set</a><span class="tok-p">();</span>
+ <a href="#xpath_node_set::ctor">xpath_node_set</a><span class="tok-p">(</span><span class="tok-n">const_iterator</span> <span class="tok-n">begin</span><span class="tok-p">,</span> <span class="tok-n">const_iterator</span> <span class="tok-n">end</span><span class="tok-p">,</span> <span class="tok-kt">type_t</span> <span class="tok-n">type</span> <span class="tok-o">=</span> <span class="tok-n">type_unsorted</span><span class="tok-p">);</span>
+
+ <span class="tok-k">typedef</span> <span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">*</span> <a href="#xpath_node_set::const_iterator">const_iterator</a><span class="tok-p">;</span>
+ <span class="tok-n">const_iterator</span> <a href="#xpath_node_set::begin">begin</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">const_iterator</span> <a href="#xpath_node_set::end">end</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">const</span> <span class="tok-n">xpath_node</span><span class="tok-o">&amp;</span> <a href="#xpath_node_set::index">operator[</a><span class="tok-p">](</span><span class="tok-kt">size_t</span> <span class="tok-n">index</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">size_t</span> <a href="#xpath_node_set::size">size</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_node_set::empty">empty</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-n">xpath_node</span> <a href="#xpath_node_set::first">first</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-k">enum</span> <span class="tok-kt">type_t</span> <span class="tok-p">{</span><a href="#xpath_node_set::type_unsorted">type_unsorted</a><span class="tok-p">,</span> <a href="#xpath_node_set::type_sorted">type_sorted</a><span class="tok-p">,</span> <a href="#xpath_node_set::type_sorted_reverse">type_sorted_reverse</a><span class="tok-p">};</span>
+ <span class="tok-kt">type_t</span> <a href="#xpath_node_set::type">type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">void</span> <a href="#xpath_node_set::sort">sort</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">reverse</span> <span class="tok-o">=</span> <span class="tok-nb">false</span><span class="tok-p">);</span>
+
+<span class="tok-k">class</span> <a href="#xpath_variable">xpath_variable</a>
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xpath_variable::name">name</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-n">xpath_value_type</span> <a href="#xpath_variable::type">type</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xpath_variable::get_boolean">get_boolean</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-kt">double</span> <a href="#xpath_variable::get_number">get_number</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <a href="#xpath_variable::get_string">get_string</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+ <span class="tok-k">const</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">&amp;</span> <a href="#xpath_variable::get_node_set">get_node_set</a><span class="tok-p">()</span> <span class="tok-k">const</span><span class="tok-p">;</span>
+
+ <span class="tok-kt">bool</span> <a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-kt">bool</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-kt">double</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_variable::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">&amp;</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+
+<span class="tok-k">class</span> <a href="#xpath_variable_set">xpath_variable_set</a>
+ <span class="tok-n">xpath_variable</span><span class="tok-o">*</span> <a href="#xpath_variable_set::add">add</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-n">xpath_value_type</span> <span class="tok-n">type</span><span class="tok-p">);</span>
+
+ <span class="tok-kt">bool</span> <a href="#xpath_variable_set::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-kt">bool</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_variable_set::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-kt">double</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_variable_set::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+ <span class="tok-kt">bool</span> <a href="#xpath_variable_set::set">set</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-k">const</span> <span class="tok-n">xpath_node_set</span><span class="tok-o">&amp;</span> <span class="tok-n">value</span><span class="tok-p">);</span>
+
+ <span class="tok-n">xpath_variable</span><span class="tok-o">*</span> <a href="#xpath_variable_set::get">get</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">);</span>
+ <span class="tok-k">const</span> <span class="tok-n">xpath_variable</span><span class="tok-o">*</span> <a href="#xpath_variable_set::get">get</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char_t</span><span class="tok-o">*</span> <span class="tok-n">name</span><span class="tok-p">)</span> <span class="tok-k">const</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="apiref.functions"><a class="anchor" href="#apiref.functions"></a>10.6. Functions</h3>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <a href="#as_utf8">as_utf8</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">wchar_t</span><span class="tok-o">*</span> <span class="tok-n">str</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <a href="#as_utf8">as_utf8</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span><span class="tok-o">&amp;</span> <span class="tok-n">str</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span> <a href="#as_wide">as_wide</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">str</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">wstring</span> <a href="#as_wide">as_wide</a><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span><span class="tok-o">&amp;</span> <span class="tok-n">str</span><span class="tok-p">);</span>
+<span class="tok-kt">void</span> <a href="#set_memory_management_functions">set_memory_management_functions</a><span class="tok-p">(</span><span class="tok-n">allocation_function</span> <span class="tok-n">allocate</span><span class="tok-p">,</span> <span class="tok-n">deallocation_function</span> <span class="tok-n">deallocate</span><span class="tok-p">);</span>
+<span class="tok-n">allocation_function</span> <a href="#get_memory_allocation_function">get_memory_allocation_function</a><span class="tok-p">();</span>
+<span class="tok-n">deallocation_function</span> <a href="#get_memory_deallocation_function">get_memory_deallocation_function</a><span class="tok-p">();</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="footnotes">
<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <b>Overview</b> |
- <a href="manual/install.html">Installation</a> |
- Document:
- <a href="manual/dom.html">Object model</a> &middot; <a href="manual/loading.html">Loading</a> &middot; <a href="manual/access.html">Accessing</a> &middot; <a href="manual/modify.html">Modifying</a> &middot; <a href="manual/saving.html">Saving</a> |
- <a href="manual/xpath.html">XPath</a> |
- <a href="manual/apiref.html">API Reference</a> |
- <a href="manual/toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav"><a accesskey="n" href="manual/install.html"><img src="images/next.png" alt="Next"></a></div></td>
-</tr></table>
+<div class="footnote" id="_footnote_1">
+<a href="#_footnoteref_1">1</a>. All trademarks used are properties of their respective owners.
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2015-04-10 20:49:27 PDT
+</div>
+</div>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/docs/manual.qbk b/docs/manual.qbk
deleted file mode 100644
index fec889a..0000000
--- a/docs/manual.qbk
+++ /dev/null
@@ -1,2771 +0,0 @@
-[book pugixml
- [quickbook 1.5]
-
- [version 1.5]
- [id manual]
- [copyright 2014 Arseny Kapoulkine]
- [license Distributed under the MIT License]
-]
-
-[template sbr[]'''<sbr/>''']
-[template lbr[]'''<sbr/><sbr/>'''] [/ for empty lines in lists]
-[template file[name]'''<filename>'''[name]'''</filename>''']
-[template sref[name]'''<xref linkend="'''[name]'''" xrefstyle="select:title" />''']
-[template anchor[name]'''<anchor id="'''[name]'''" />'''[^[name]]]
-[template ftnt[id text]'''<footnote id="'''[id]'''"><para>'''[text]'''</para></footnote>''']
-
-[section:overview Overview]
-
-[section:introduction Introduction]
-
-[@http://pugixml.org/ pugixml] is a light-weight C++ XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an [link manual.xpath XPath 1.0 implementation] for complex data-driven tree queries. Full Unicode support is also available, with [link manual.dom.unicode two Unicode interface variants] and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is [link manual.install.portability extremely portable] and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the [link manual.overview.license MIT license], making it completely free to use in both open-source and proprietary applications.
-
-pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can't process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD or XML Schema validation, the library is not for you.
-
-This is the complete manual for pugixml, which describes all features of the library in detail. If you want to start writing code as quickly as possible, you are advised to [@quickstart.html read the quick start guide first].
-
-[note No documentation is perfect, neither is this one. If you encounter a description that is unclear, please file an issue as described in [sref manual.overview.feedback]. Also if you can spare the time for a full proof-reading, including spelling and grammar, that would be great! Please [link email send me an e-mail]; as a token of appreciation, your name will be included into the [link manual.overview.thanks corresponding section] of this documentation.]
-
-[endsect] [/introduction]
-
-[section:feedback Feedback]
-
-If you believe you've found a bug in pugixml (bugs include compilation problems (errors/warnings), crashes, performance degradation and incorrect behavior), please file an issue via [@https://github.com/zeux/pugixml/issues/new issue submission form]. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc.
-
-Feature requests can be reported the same way as bugs, so if you're missing some functionality in pugixml or if the API is rough in some places and you can suggest an improvement, [@https://github.com/zeux/pugixml/issues/new file an issue]. However please note that there are many factors when considering API changes (compatibility with previous versions, API redundancy, etc.), so generally features that can be implemented via a small function without pugixml modification are not accepted. However, all rules have exceptions.
-
-If you have a contribution to pugixml, such as build script for some build system/IDE, or a well-designed set of helper functions, or a binding to some language other than C++, please [@https://github.com/zeux/pugixml/issues/new file an issue]. You can include the relevant patches as issue attachments. Your contribution has to be distributed under the terms of a license that's compatible with pugixml license; i.e. GPL/LGPL licensed code is not accepted.
-
-[#email]
-If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: [@mailto:arseny.kapoulkine@gmail.com arseny.kapoulkine@gmail.com].
-
-[endsect] [/feedback]
-
-[section:thanks Acknowledgments]
-
-pugixml could not be developed without the help from many people; some of them are listed in this section. If you've played a part in pugixml development and you can not find yourself on this list, I'm truly sorry; please [link email send me an e-mail] so I can fix this.
-
-Thanks to *Kristen Wegner* for pugxml parser, which was used as a basis for pugixml.
-
-Thanks to *Neville Franks* for contributions to pugxml parser.
-
-Thanks to *Artyom Palvelev* for suggesting a lazy gap contraction approach.
-
-Thanks to *Vyacheslav Egorov* for documentation proofreading.
-
-[endsect] [/thanks]
-
-[section:license License]
-
-The pugixml library is distributed under the MIT license:
-
-[:
-Copyright (c) 2006-2014 Arseny Kapoulkine
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-]
-
-This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
-
-[:
-This software is based on pugixml library (http://pugixml.org).'''<sbr />'''
-pugixml is Copyright (C) 2006-2014 Arseny Kapoulkine.
-]
-
-[endsect] [/license]
-
-[endsect] [/overview]
-
-[section:install Installation]
-
-[section:getting Getting pugixml]
-
-pugixml is distributed in source form. You can either download a source distribution or clone the Git repository.
-
-[section:source Source distributions]
-
-You can download the latest source distribution via one of the following links:
-
-[pre
-[@https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.zip]
-[@https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.tar.gz]
-]
-
-The distribution contains library source, documentation (the manual you're reading now and the quick start guide) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive. The files have different line endings depending on the archive format - [file .zip] archive has Windows line endings, [file .tar.gz] archive has Unix line endings. Otherwise the files in both archives are identical.
-
-If you need an older version, you can download it from the [@https://github.com/zeux/pugixml/releases version archive].
-
-[endsect] [/source]
-
-[section:git Git repository]
-
-The Git repository is located at [@https://github.com/zeux/pugixml/]. There is a Git tag "v{version}" for each version; also there is the "latest" tag, which always points to the latest stable release.
-
-For example, to checkout the current version, you can use this command:
-
-[pre
-git clone https://github.com/zeux/pugixml
-cd pugixml
-git checkout v1.5
-]
-
-The repository contains library source, documentation, code examples and full unit test suite.
-
-Use latest version tag if you want to automatically get new versions. Use other tags if you want to switch to new versions only explicitly. Also please note that the master branch contains the work-in-progress version of the code; while this means that you can get new features and bug fixes from master without waiting for a new release, this also means that occasionally the code can be broken in some configurations.
-
-[endsect] [/git]
-
-[section:subversion Subversion repository]
-
-You can access the Git repository via Subversion using [@https://github.com/zeux/pugixml] URL. For example, to checkout the current version, you can use this command:
-
-[pre svn checkout https://github.com/zeux/pugixml/tags/v1.5 pugixml]
-
-[endsect] [/subversion]
-
-[endsect] [/getting]
-
-[section:building Building pugixml]
-
-pugixml is distributed in source form without any pre-built binaries; you have to build them yourself.
-
-The complete pugixml source consists of three files - one source file, [file pugixml.cpp], and two header files, [file pugixml.hpp] and [file pugiconfig.hpp]. [file pugixml.hpp] is the primary header which you need to include in order to use pugixml classes/functions; [file pugiconfig.hpp] is a supplementary configuration file (see [sref manual.install.building.config]). The rest of this guide assumes that [file pugixml.hpp] is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
-
-[section:embed Building pugixml as a part of another static library/executable]
-
-The easiest way to build pugixml is to compile the source file, [file pugixml.cpp], along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio[ftnt trademarks All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just add [file pugixml.cpp] to one of your projects.
-
-If you're using Microsoft Visual Studio and the project has precompiled headers turned on, you'll see the following error messages:
-
-[pre pugixml.cpp(3477) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?]
-
-The correct way to resolve this is to disable precompiled headers for [file pugixml.cpp]; you have to set "Create/Use Precompiled Header" option (Properties dialog -> C/C++ -> Precompiled Headers -> Create/Use Precompiled Header) to "Not Using Precompiled Headers". You'll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option):
-
-[table
-[[
-[@images/vs2005_pch1.png [$images/vs2005_pch1_thumb.png]]
-[$images/next.png]
-[@images/vs2005_pch2.png [$images/vs2005_pch2_thumb.png]]
-[$images/next.png]
-[@images/vs2005_pch3.png [$images/vs2005_pch3_thumb.png]]
-[$images/next.png]
-[@images/vs2005_pch4.png [$images/vs2005_pch4_thumb.png]]
-]] ]
-
-[endsect] [/embed]
-
-[section:static Building pugixml as a standalone static library]
-
-It's possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode3, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010, and configuration scripts for CMake and premake4. You're welcome to submit project files/build scripts for other software; see [sref manual.overview.feedback].
-
-There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like [file pugixml_vs2008.vcproj], and another one for statically linked CRT, which has a name like [file pugixml_vs2008_static.vcproj]. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. [file pugixml_vs2008.vcproj] for Microsoft Visual Studio 2008).
-
-In addition to adding pugixml project to your workspace, you'll have to make sure that your application links with pugixml library. If you're using Microsoft Visual Studio 2005/2008, you can add a dependency from your application project to pugixml one. If you're using Microsoft Visual Studio 2010, you'll have to add a reference to your application project instead. For other IDEs/systems, consult the relevant documentation.
-
-[table
-[[Microsoft Visual Studio 2005/2008][Microsoft Visual Studio 2010]]
-[[
-[@images/vs2005_link1.png [$images/vs2005_link1_thumb.png]]
-[$images/next.png]
-[@images/vs2005_link2.png [$images/vs2005_link2_thumb.png]]
-][
-[@images/vs2010_link1.png [$images/vs2010_link1_thumb.png]]
-[$images/next.png]
-[@images/vs2010_link2.png [$images/vs2010_link2_thumb.png]]
-]] ]
-
-[endsect] [/static]
-
-[section:shared Building pugixml as a standalone shared library]
-
-It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining [link PUGIXML_API] macro, i.e. via [file pugiconfig.hpp]:
-
- #ifdef _DLL
- #define PUGIXML_API __declspec(dllexport)
- #else
- #define PUGIXML_API __declspec(dllimport)
- #endif
-
-[caution If you're using STL-related functions, you should use the shared runtime library to ensure that a single heap is used for STL allocations in your application and in pugixml; in MSVC, this means selecting the 'Multithreaded DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (/MD or /MDd linker switch). You should also make sure that your runtime library choice is consistent between different projects.]
-
-[endsect] [/shared]
-
-[#PUGIXML_HEADER_ONLY]
-[section:header Using pugixml in header-only mode]
-
-It's possible to use pugixml in header-only mode. This means that all source code for pugixml will be included in every translation unit that includes [file pugixml.hpp]. This is how most of Boost and STL libraries work.
-
-Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using [link PUGIXML_NO_XPATH] define to improve compilation time.
-
-Enabling header-only mode is a two-step process:
-
-# You have to define `PUGIXML_HEADER_ONLY`
-# You have to include [file pugixml.cpp] whenever you include pugixml.hpp
-
-Both of these are best done via [file pugiconfig.hpp] like this:
-
- #define PUGIXML_HEADER_ONLY
- #include "pugixml.cpp"
-
-Note that it is safe to compile [file pugixml.cpp] if `PUGIXML_HEADER_ONLY` is defined - so if you want to i.e. use header-only mode only in Release configuration, you
-can include pugixml.cpp in your project (see [sref manual.install.building.embed]), and conditionally enable header-only mode in [file pugiconfig.hpp], i.e.:
-
- #ifndef _DEBUG
- #define PUGIXML_HEADER_ONLY
- #include "pugixml.cpp"
- #endif
-
-[endsect] [/header]
-
-[section:config Additional configuration options]
-
-pugixml uses several defines to control the compilation process. There are two ways to define them: either put the needed definitions to [file pugiconfig.hpp] (it has some examples that are commented out) or provide them via compiler command-line. Consistency is important: the definitions should match in all source files that include [file pugixml.hpp] (including pugixml sources) throughout the application. Adding defines to [file pugiconfig.hpp] lets you guarantee this, unless your macro definition is wrapped in preprocessor `#if`/`#ifdef` directive and this directive is not consistent. [file pugiconfig.hpp] will never contain anything but comments, which means that when upgrading to a new version, you can safely leave your modified version intact.
-
-[anchor PUGIXML_WCHAR_MODE] define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use `char` as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on `wchar_t` size, most functions use `wchar_t` as character type). See [sref manual.dom.unicode] for more details.
-
-[anchor PUGIXML_NO_XPATH] define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space.
-
-[anchor PUGIXML_NO_STL] define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation.
-
-[anchor PUGIXML_NO_EXCEPTIONS] define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities.
-
-[anchor PUGIXML_API], [anchor PUGIXML_CLASS] and [anchor PUGIXML_FUNCTION] defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of `PUGIXML_CLASS` or `PUGIXML_FUNCTION` definitions, `PUGIXML_API` definition is used instead. For example, to specify fixed calling convention, you can define `PUGIXML_FUNCTION` to i.e. `__fastcall`. Another example is DLL import/export attributes in MSVC (see [sref manual.install.building.shared]).
-
-[note In that example `PUGIXML_API` is inconsistent between several source files; this is an exception to the consistency rule.]
-
-[anchor PUGIXML_MEMORY_PAGE_SIZE], [anchor PUGIXML_MEMORY_OUTPUT_STACK] and [anchor PUGIXML_MEMORY_XPATH_PAGE_SIZE] can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see [sref manual.dom.memory.tuning].
-
-[anchor PUGIXML_HAS_LONG_LONG] define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C++-11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually.
-
-[endsect] [/config]
-
-[endsect] [/building]
-
-[section:portability Portability]
-
-pugixml is written in standard-compliant C++ with some compiler-specific workarounds where appropriate. pugixml is compatible with the C++11 standard, but does not require C++11 support. Each version is tested with a unit test suite (with code coverage about 99%) on the following platforms:
-
-* Microsoft Windows:
- * Borland C++ Compiler 5.82
- * Digital Mars C++ Compiler 8.51
- * Intel C++ Compiler 8.0, 9.0 x86/x64, 10.0 x86/x64, 11.0 x86/x64
- * Metrowerks CodeWarrior 8.0
- * Microsoft Visual C++ 6.0, 7.0 (2002), 7.1 (2003), 8.0 (2005) x86/x64, 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 (2011) x86/x64/ARM, 12.0 (2013) x86/x64/ARM and some CLR versions
- * MinGW (GCC) 3.4, 4.4, 4.5, 4.6 x64
-
-* Linux (GCC 4.4.3 x86/x64, GCC 4.8.1 x64, Clang 3.2 x64)
-* FreeBSD (GCC 4.2.1 x86/x64)
-* Apple MacOSX (GCC 4.0.1 x86/x64/PowerPC)
-* Sun Solaris (sunCC x86/x64)
-* Microsoft Xbox 360
-* Nintendo Wii (Metrowerks CodeWarrior 4.1)
-* Sony Playstation Portable (GCC 3.4.2)
-* Sony Playstation 3 (GCC 4.1.1, SNC 310.1)
-* Various portable platforms (Android NDK, BlackBerry NDK, Samsung bada, Windows CE)
-
-[endsect] [/portability]
-
-[endsect] [/install]
-
-[section:dom Document object model]
-
-pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from a character stream (file, string, C++ I/O stream), then traversed with the special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C++ I/O stream or custom transport).
-
-[section:tree Tree structure]
-
-The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C++ type [link xml_document]. Document has one or more child nodes, which correspond to C++ type [link xml_node]. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C++ type [link xml_attribute], and some additional data (i.e. name).
-
-[#xml_node_type]
-The tree nodes can be of one of the following types (which together form the enumeration `xml_node_type`):
-
-* Document node ([anchor node_document]) - this is the root of the tree, which consists of several child nodes. This node corresponds to [link xml_document] class; note that [link xml_document] is a sub-class of [link xml_node], so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation.
-[lbr]
-
-* Element/tag node ([anchor node_element]) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:
-
- <node attr="value"><child/></node>
-
-[:There are two element nodes here: one has name `"node"`, single attribute `"attr"` and single child `"child"`, another has name `"child"` and does not have any attributes or child nodes.]
-
-* Plain character data nodes ([anchor node_pcdata]) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:
-
- <node> text1 <child/> text2 </node>
-
-[:Here `"node"` element has three children, two of which are PCDATA nodes with values `" text1 "` and `" text2 "`.]
-
-* Character data nodes ([anchor node_cdata]) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA:
-
- <node> <![CDATA[[text1]]> <child/> <![CDATA[[text2]]> </node>
-
-[:CDATA nodes make it easy to include non-escaped <, & and > characters in plain text. CDATA value can not contain the character sequence \]\]>, since it is used to determine the end of node contents.]
-
-* Comment nodes ([anchor node_comment]) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows:
-
- <!-- comment text -->
-
-[:Here the comment node has value `"comment text"`. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_comments] flag.]
-
-* Processing instruction node ([anchor node_pi]) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows:
-
- <?name value?>
-
-[:Here the name (also called PI target) is `"name"`, and the value is `"value"`. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_pi] flag.]
-
-* Declaration node ([anchor node_declaration]) represents document declarations in XML. Declaration nodes have a name (`"xml"`) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:
-
- <?xml version="1.0"?>
-
-[:Here the node has name `"xml"` and a single attribute with name `"version"` and value `"1.0"`. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_declaration] flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with [link format_no_declaration] flag.]
-
-* Document type declaration node ([anchor node_doctype]) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like `<!ENTITY>`. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:
-
- <!DOCTYPE greeting [ <!ELEMENT greeting (#PCDATA)> ]>
-
-[:Here the node has value `"greeting [ <!ELEMENT greeting (#PCDATA)> ]"`. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with [link parse_doctype] flag.]
-
-Finally, here is a complete example of XML document and the corresponding tree representation ([@samples/tree.xml]):
-
-[table
-
-[[
-``
- <?xml version="1.0"?>
- <mesh name="mesh_root">
- <!-- here is a mesh node -->
- some text
- <![CDATA[someothertext]]>
- some more text
- <node attr1="value1" attr2="value2" />
- <node attr1="value2">
- <innernode/>
- </node>
- </mesh>
- <?include somedata?>
-``
-][
-[@images/dom_tree.png [$images/dom_tree_thumb.png]]
-]]]
-
-
-[endsect] [/tree]
-
-[section:cpp C++ interface]
-
-[note All pugixml classes and functions are located in the `pugi` namespace; you have to either use explicit name qualification (i.e. `pugi::xml_node`), or to gain access to relevant symbols via `using` directive (i.e. `using pugi::xml_node;` or `using namespace pugi;`). The namespace will be omitted from all declarations in this documentation hereafter; all code examples will use fully qualified names.]
-
-Despite the fact that there are several node types, there are only three C++ classes representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. The classes are described below.
-
-[#xml_document]
-[#xml_document::document_element]
-`xml_document` is the owner of the entire document structure; it is a non-copyable class. The interface of `xml_document` consists of loading functions (see [sref manual.loading]), saving functions (see [sref manual.saving]) and the entire interface of `xml_node`, which allows for document inspection and/or modification. Note that while `xml_document` is a sub-class of `xml_node`, `xml_node` is not a polymorphic type; the inheritance is present only to simplify usage. Alternatively you can use the `document_element` function to get the element node that's the immediate child of the document.
-
-[#xml_document::ctor]
-[#xml_document::dtor]
-[#xml_document::reset]
-Default constructor of `xml_document` initializes the document to the tree with only a root node (document node). You can then populate it with data using either tree modification functions or loading functions; all loading functions destroy the previous tree with all occupied memory, which puts existing node/attribute handles for this document to invalid state. If you want to destroy the previous tree, you can use the `xml_document::reset` function; it destroys the tree and replaces it with either an empty one or a copy of the specified document. Destructor of `xml_document` also destroys the tree, thus the lifetime of the document object should exceed the lifetimes of any node/attribute handles that point to the tree.
-
-[caution While technically node/attribute handles can be alive when the tree they're referring to is destroyed, calling any member function for these handles results in undefined behavior. Thus it is recommended to make sure that the document is destroyed only after all references to its nodes/attributes are destroyed.]
-
-[#xml_node]
-[#xml_node::type]
-`xml_node` is the handle to document node; it can point to any node in the document, including the document node itself. There is a common interface for nodes of all types; the actual [link xml_node_type node type] can be queried via the `xml_node::type()` method. Note that `xml_node` is only a handle to the actual node, not the node itself - you can have several `xml_node` handles pointing to the same underlying object. Destroying `xml_node` handle does not destroy the node and does not remove it from the tree. The size of `xml_node` is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return `xml_node` objects by value without additional overhead.
-
-[#node_null]
-There is a special value of `xml_node` type, known as null node or empty node (such nodes have type `node_null`). It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don't do anything and return empty nodes/attributes or empty strings as their result (see documentation for specific functions for more detailed information). This is useful for chaining calls; i.e. you can get the grandparent of a node like so: `node.parent().parent()`; if a node is a null node or it does not have a parent, the first `parent()` call returns null node; the second `parent()` call then also returns null node, which makes error handling easier.
-
-[#xml_attribute]
-`xml_attribute` is the handle to an XML attribute; it has the same semantics as `xml_node`, i.e. there can be several `xml_attribute` handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.
-
-[#xml_attribute::ctor]
-[#xml_node::ctor]
-Both `xml_node` and `xml_attribute` have the default constructor which initializes them to null objects.
-
-[#xml_attribute::comparison]
-[#xml_node::comparison]
-`xml_node` and `xml_attribute` try to behave like pointers, that is, they can be compared with other objects of the same type, making it possible to use them as keys in associative containers. All handles to the same underlying object are equal, and any two handles to different underlying objects are not equal. Null handles only compare as equal to themselves. The result of relational comparison can not be reliably determined from the order of nodes in file or in any other way. Do not use relational comparison operators except for search optimization (i.e. associative container keys).
-
-[#xml_attribute::hash_value]
-[#xml_node::hash_value]
-If you want to use `xml_node` or `xml_attribute` objects as keys in hash-based associative containers, you can use the `hash_value` member functions. They return the hash values that are guaranteed to be the same for all handles to the same underlying object. The hash value for null handles is 0.
-
-[#xml_attribute::unspecified_bool_type]
-[#xml_node::unspecified_bool_type]
-[#xml_attribute::empty]
-[#xml_node::empty]
-Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node\/attribute is empty with the following code: `if (node) { ... }` or `if (!node) { ... } else { ... }`. Alternatively you can check if a given `xml_node`/`xml_attribute` handle is null by calling the following methods:
-
- bool xml_attribute::empty() const;
- bool xml_node::empty() const;
-
-Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling [link xml_node::remove_child]) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.
-
-[endsect] [/cpp]
-
-[section:unicode Unicode interface]
-
-There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via [link PUGIXML_WCHAR_MODE] define; you can set it via [file pugiconfig.hpp] or via preprocessor options, as discussed in [sref manual.install.building.config]. If this define is set, the wchar_t interface is used; otherwise (by default) the char interface is used. The exact wide character encoding is assumed to be either UTF-16 or UTF-32 and is determined based on the size of `wchar_t` type.
-
-[note If the size of `wchar_t` is 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some characters are represented as two code points.]
-
-All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode:
-
- const char* xml_node::name() const;
- bool xml_node::set_name(const char* value);
-
-and like this in wchar_t mode:
-
- const wchar_t* xml_node::name() const;
- bool xml_node::set_name(const wchar_t* value);
-
-[#char_t]
-[#string_t]
-There is a special type, `pugi::char_t`, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type `pugi::string_t`, which is defined as the STL string of the character type; it corresponds to `std::string` in char mode and to `std::wstring` in wchar_t mode.
-
-In addition to the interface, the internal implementation changes to store XML data as `pugi::char_t`; this means that these two modes have different memory usage characteristics. The conversion to `pugi::char_t` upon document loading and from `pugi::char_t` upon document saving happen automatically, which also carries minor performance penalty. The general advice however is to select the character mode based on usage scenario, i.e. if UTF-8 is inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice.
-
-[#as_utf8]
-[#as_wide]
-There are cases when you'll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes:
-
- std::string as_utf8(const wchar_t* str);
- std::wstring as_wide(const char* str);
-
-Both functions accept a null-terminated string as an argument `str`, and return the converted string. `as_utf8` performs conversion from UTF-16/32 to UTF-8; `as_wide` performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. `str` has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument:
-
- std::string as_utf8(const std::wstring& str);
- std::wstring as_wide(const std::string& str);
-
-[note Most examples in this documentation assume char interface and therefore will not compile with [link PUGIXML_WCHAR_MODE]. This is done to simplify the documentation; usually the only changes you'll have to make is to pass `wchar_t` string literals, i.e. instead of
-
-`pugi::xml_node node = doc.child("bookstore").find_child_by_attribute("book", "id", "12345");`
-
-you'll have to do
-
-`pugi::xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");`]
-
-[endsect] [/unicode]
-
-[section:thread Thread-safety guarantees]
-
-Almost all functions in pugixml have the following thread-safety guarantees:
-
-* it is safe to call free (non-member) functions from multiple threads
-* it is safe to perform concurrent read-only accesses to the same tree (all constant member functions do not modify the tree)
-* it is safe to perform concurrent read/write accesses, if there is only one read or write access to the single tree at a time
-
-Concurrent modification and traversing of a single tree requires synchronization, for example via reader-writer lock. Modification includes altering document structure and altering individual node/attribute data, i.e. changing names/values.
-
-The only exception is [link set_memory_management_functions]; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see [sref manual.dom.memory.custom].
-
-[endsect] [/thread]
-
-[section:exception Exception guarantees]
-
-With the exception of XPath, pugixml itself does not throw any exceptions. Additionally, most pugixml functions have a no-throw exception guarantee.
-
-This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. [link xml_node::traverse] or [link xml_node::find_node]) do not provide any exception guarantees beyond the ones provided by the callback.
-
-If exception handling is not disabled with [link PUGIXML_NO_EXCEPTIONS] define, XPath functions may throw [link xpath_exception] on parsing errors; also, XPath functions may throw `std::bad_alloc` in low memory conditions. Still, XPath functions provide strong exception guarantee.
-
-[endsect] [/exception]
-
-[section:memory Memory management]
-
-pugixml requests the memory needed for document storage in big chunks, and allocates document data inside those chunks. This section discusses replacing functions used for chunk allocation and internal memory management implementation.
-
-[section:custom Custom memory allocation/deallocation functions]
-
-[#allocation_function]
-[#deallocation_function]
-All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free:
-
- typedef void* (*allocation_function)(size_t size);
- typedef void (*deallocation_function)(void* ptr);
-
-[#set_memory_management_functions]
-[#get_memory_allocation_function]
-[#get_memory_deallocation_function]
-You can use the following accessor functions to change or get current memory management functions:
-
- void set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
- allocation_function get_memory_allocation_function();
- deallocation_function get_memory_deallocation_function();
-
-Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of `void*` and `double` types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to return null pointer (throwing an exception from allocation function results in undefined behavior).
-
-Deallocation function is called with the pointer that was returned by some call to allocation function; it is never called with a null pointer. If memory management functions are not thread-safe, library thread safety is not guaranteed.
-
-This is a simple example of custom memory management ([@samples/custom_memory_management.cpp]):
-
-[import samples/custom_memory_management.cpp]
-[code_custom_memory_management_decl]
-[code_custom_memory_management_call]
-
-When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.
-
-[endsect] [/custom]
-
-[section:tuning Memory consumption tuning]
-
-There are several important buffering optimizations in pugixml that rely on predefined constants. These constants have default values that were tuned for common usage patterns; for some applications, changing these constants might improve memory consumption or increase performance. Changing these constants is not recommended unless their default values result in visible problems.
-
-These constants can be tuned via configuration defines, as discussed in [sref manual.install.building.config]; it is recommended to set them in [file pugiconfig.hpp].
-
-* `PUGIXML_MEMORY_PAGE_SIZE` controls the page size for document memory allocation. Memory for node/attribute objects is allocated in pages of the specified size. The default size is 32 Kb; for some applications the size is too large (i.e. embedded systems with little heap space or applications that keep lots of XML documents in memory). A minimum size of 1 Kb is recommended.
-[lbr]
-
-* `PUGIXML_MEMORY_OUTPUT_STACK` controls the cumulative stack space required to output the node. Any output operation (i.e. saving a subtree to file) uses an internal buffering scheme for performance reasons. The default size is 10 Kb; if you're using node output from threads with little stack space, decreasing this value can prevent stack overflows. A minimum size of 1 Kb is recommended.
-[lbr]
-
-* `PUGIXML_MEMORY_XPATH_PAGE_SIZE` controls the page size for XPath memory allocation. Memory for XPath query objects as well as internal memory for XPath evaluation is allocated in pages of the specified size. The default size is 4 Kb; if you have a lot of resident XPath query objects, you might need to decrease the size to improve memory consumption. A minimum size of 256 bytes is recommended.
-
-[endsect] [/tuning]
-
-[section:internals Document memory management internals]
-
-Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the [link xml_document] object.
-
-When the document is loaded from file/buffer, unless an inplace loading function is used (see [sref manual.loading.memory]), a complete copy of character stream is made; all names/values of nodes and attributes are allocated in this buffer. This buffer is allocated via a single large allocation and is only freed when document memory is reclaimed (i.e. if the [link xml_document] object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns.
-
-All additional memory, such as memory for document structure (node/attribute objects) and memory for node/attribute names/values is allocated in pages on the order of 32 kilobytes; actual objects are allocated inside the pages using a memory management scheme optimized for fast allocation/deallocation of many small objects. Because of the scheme specifics, the pages are only destroyed if all objects inside them are destroyed; also, generally destroying an object does not mean that subsequent object creation will reuse the same memory. This means that it is possible to devise a usage scheme which will lead to higher memory usage than expected; one example is adding a lot of nodes, and them removing all even numbered ones; not a single page is reclaimed in the process. However this is an example specifically crafted to produce unsatisfying behavior; in all practical usage scenarios the memory consumption is less than that of a general-purpose allocator because allocation meta-data is very small in size.
-
-[endsect] [/internals]
-
-[endsect] [/memory]
-
-[endsect] [/dom]
-
-[section:loading Loading document]
-
-pugixml provides several functions for loading XML data from various places - files, C++ iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed for performance reasons. Also some XML transformations (i.e. EOL handling or attribute value normalization) can impact parsing speed and thus can be disabled. However for vast majority of XML documents there is no performance difference between different parsing options. Parsing options also control whether certain XML nodes are parsed; see [sref manual.loading.options] for more information.
-
-XML data is always converted to internal character format (see [sref manual.dom.unicode]) before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions automatically. Unless explicit encoding is specified, loading functions perform automatic encoding detection based on first few characters of XML data, so in almost all cases you do not have to specify document encoding. Encoding conversion is described in more detail in [sref manual.loading.encoding].
-
-[section:file Loading document from file]
-
-[#xml_document::load_file]
-[#xml_document::load_file_wide]
-The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:
-
- xml_parse_result xml_document::load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result xml_document::load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see [sref manual.loading.options]) and input data encoding (see [sref manual.loading.encoding]). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.
-
-File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.
-
-`load_file` destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an [link xml_parse_result] object; this object contains the operation status and the related information (i.e. last successfully parsed position in the input file, if parsing fails). See [sref manual.loading.errors] for error handling details.
-
-This is an example of loading XML document from file ([@samples/load_file.cpp]):
-
-[import samples/load_file.cpp]
-[code_load_file]
-
-[endsect] [/file]
-
-[section:memory Loading document from memory]
-
-[#xml_document::load_buffer]
-[#xml_document::load_buffer_inplace]
-[#xml_document::load_buffer_inplace_own]
-Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage:
-
- xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-All functions accept the buffer which is represented by a pointer to XML data, `contents`, and data size in bytes. Also there are two optional arguments, which specify parsing options (see [sref manual.loading.options]) and input data encoding (see [sref manual.loading.encoding]). The buffer does not have to be zero-terminated.
-
-`load_buffer` function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - `load_buffer_inplace` and `load_buffer_inplace_own` store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer's lifetime exceeds that of the tree if you're using inplace functions. In addition to that, `load_buffer_inplace` does not assume ownership of the buffer, so you'll have to destroy it yourself; `load_buffer_inplace_own` assumes ownership of the buffer and destroys it once it is not needed. This means that if you're using `load_buffer_inplace_own`, you have to allocate memory with pugixml allocation function (you can get it via [link get_memory_allocation_function]).
-
-The best way from the performance/memory point of view is to load document using `load_buffer_inplace_own`; this function has maximum control of the buffer with XML data so it is able to avoid redundant copies and reduce peak memory usage while parsing. This is the recommended function if you have to load the document from memory and performance is critical.
-
-[#xml_document::load_string]
-There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:
-
- xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options = parse_default);
-
-It is equivalent to calling `load_buffer` with `size` being either `strlen(contents)` or `wcslen(contents) * sizeof(wchar_t)`, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.
-
-This is an example of loading XML document from memory using different functions ([@samples/load_memory.cpp]):
-
-[import samples/load_memory.cpp]
-[code_load_memory_decl]
-[code_load_memory_buffer]
-[code_load_memory_buffer_inplace]
-[code_load_memory_buffer_inplace_own]
-[code_load_memory_string]
-
-[endsect] [/memory]
-
-[section:stream Loading document from C++ IOstreams]
-
-[#xml_document::load_stream]
-To enhance interoperability, pugixml provides functions for loading document from any object which implements C++ `std::istream` interface. This allows you to load documents from any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones:
-
- xml_parse_result xml_document::load(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
- xml_parse_result xml_document::load(std::wistream& stream, unsigned int options = parse_default);
-
-`load` with `std::istream` argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling `xml_document::load` on an opened `std::ifstream` object is equivalent to calling `xml_document::load_file`.
-
-`load` with `std::wstream` argument treats the stream contents as a wide character stream (encoding is always [link encoding_wchar]). Because of this, using `load` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale.
-
-This is a simple example of loading XML document from file using streams ([@samples/load_stream.cpp]); read the sample code for more complex examples involving wide streams and locales:
-
-[import samples/load_stream.cpp]
-[code_load_stream]
-
-[endsect] [/stream]
-
-[section:errors Handling parsing errors]
-
-[#xml_parse_result]
-All document loading functions return the parsing result via `xml_parse_result` object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream:
-
- struct xml_parse_result
- {
- xml_parse_status status;
- ptrdiff_t offset;
- xml_encoding encoding;
-
- operator bool() const;
- const char* description() const;
- };
-
-[#xml_parse_status]
-[#xml_parse_result::status]
-Parsing status is represented as the `xml_parse_status` enumeration and can be one of the following:
-
-* [anchor status_ok] means that no error was encountered during parsing; the source stream represents the valid XML document which was fully parsed and converted to a tree.
-[lbr]
-
-* [anchor status_file_not_found] is only returned by `load_file` function and means that file could not be opened.
-* [anchor status_io_error] is returned by `load_file` function and by `load` functions with `std::istream`/`std::wstream` arguments; it means that some I/O error has occurred during reading the file/stream.
-* [anchor status_out_of_memory] means that there was not enough memory during some allocation; any allocation failure during parsing results in this error.
-* [anchor status_internal_error] means that something went horribly wrong; currently this error does not occur
-[lbr]
-
-* [anchor status_unrecognized_tag] means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as [^#].
-* [anchor status_bad_pi] means that parsing stopped due to incorrect document declaration/processing instruction
-* [anchor status_bad_comment], [anchor status_bad_cdata], [anchor status_bad_doctype] and [anchor status_bad_pcdata] mean that parsing stopped due to the invalid construct of the respective type
-* [anchor status_bad_start_element] means that parsing stopped because starting tag either had no closing `>` symbol or contained some incorrect symbol
-* [anchor status_bad_attribute] means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that `<node attr=1>` is incorrect in XML)
-* [anchor status_bad_end_element] means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and `>`)
-* [anchor status_end_element_mismatch] means that parsing stopped because the closing tag did not match the opening one (i.e. `<node></nedo>`) or because some tag was not closed at all
-* [anchor status_no_document_element] means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document
-
-[#xml_parse_result::description]
-`description()` member function can be used to convert parsing status to a string; the returned message is always in English, so you'll have to write your own function if you need a localized string. However please note that the exact messages returned by `description()` function may change from version to version, so any complex status handling should be based on `status` value. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call [link as_wide] to get the `wchar_t` string.
-
-If parsing failed because the source data was not a valid XML, the resulting tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that was successfully parsed. Obviously, the last element may have an unexpected name/value; for example, if the attribute value does not end with the necessary quotation mark, like in [^<node attr="value>some data</node>] example, the value of attribute `attr` will contain the string `value>some data</node>`.
-
-[#xml_parse_result::offset]
-In addition to the status code, parsing result has an `offset` member, which contains the offset of last successfully parsed character if parsing failed because of an error in source data; otherwise `offset` is 0. For parsing efficiency reasons, pugixml does not track the current line during parsing; this offset is in units of [link char_t pugi::char_t] (bytes for character mode, wide characters for wide character mode). Many text editors support 'Go To Position' feature - you can use it to locate the exact error position. Alternatively, if you're loading the document from memory, you can display the error chunk along with the error description (see the example code below).
-
-[caution Offset is calculated in the XML buffer in native encoding; if encoding conversion is performed during parsing, offset can not be used to reliably track the error position.]
-
-[#xml_parse_result::encoding]
-Parsing result also has an `encoding` member, which can be used to check that the source data encoding was correctly guessed. It is equal to the exact encoding used during parsing (i.e. with the exact endianness); see [sref manual.loading.encoding] for more information.
-
-[#xml_parse_result::bool]
-Parsing result object can be implicitly converted to `bool`; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a `bool`: `if (doc.load_file("file.xml")) { ... } else { ... }`.
-
-This is an example of handling loading errors ([@samples/load_error_handling.cpp]):
-
-[import samples/load_error_handling.cpp]
-[code_load_error_handling]
-
-[endsect] [/errors]
-
-[section:options Parsing options]
-
-All document loading functions accept the optional parameter `options`. This is a bitmask that customizes the parsing process: you can select the node types that are parsed and various transformations that are performed with the XML text. Disabling certain transformations can improve parsing performance for some documents; however, the code for all transformations is very well optimized, and thus the majority of documents won't get any performance benefit. As a rule of thumb, only modify parsing flags if you want to get some nodes in the document that are excluded by default (i.e. declaration or comment nodes).
-
-[note You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use `mask | flag`; to disable a flag, use `mask & ~flag`.]
-
-These flags control the resulting tree contents:
-
-* [anchor parse_declaration] determines if XML document declaration (node with type [link node_declaration]) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_doctype] determines if XML document type declaration (node with type [link node_doctype]) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_pi] determines if processing instructions (nodes with type [link node_pi]) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. Note that `<?xml ...?>` (document declaration) is not considered to be a PI. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_comments] determines if comments (nodes with type [link node_comment]) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_cdata] determines if CDATA sections (nodes with type [link node_cdata]) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is *on* by default.
-[lbr]
-
-* [anchor parse_trim_pcdata] determines if leading and trailing whitespace characters are to be removed from PCDATA nodes. While for some applications leading/trailing whitespace is significant, often the application only cares about the non-whitespace contents so it's easier to trim whitespace from text during parsing. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_ws_pcdata] determines if PCDATA nodes (nodes with type [link node_pcdata]) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string `<node> <a/> </node>`, `<node>` element will have three children when `parse_ws_pcdata` is set (child with type [link node_pcdata] and value `" "`, child with type [link node_element] and name `"a"`, and another child with type [link node_pcdata] and value `" "`), and only one child when `parse_ws_pcdata` is not set. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_ws_pcdata_single] determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. `<node> </node>`, but is not interested in whitespace markup elsewhere. It is possible to use [link parse_ws_pcdata] flag in this case, but it results in excessive allocations and complicates document processing in some cases; this flag is intended to avoid that. As an example, after parsing XML string `<node> <a> </a> </node>` with `parse_ws_pcdata_single` flag set, `<node>` element will have one child `<a>`, and `<a>` element will have one child with type [link node_pcdata] and value `" "`. This flag has no effect if [link parse_ws_pcdata] is enabled. This flag is *off* by default.
-[lbr]
-
-* [anchor parse_fragment] determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid. This flag is *off* by default.
-
-[caution Using in-place parsing ([link xml_document::load_buffer_inplace load_buffer_inplace]) with `parse_fragment` flag may result in the loss of the last character of the buffer if it is a part of PCDATA. Since PCDATA values are null-terminated strings, the only way to resolve this is to provide a null-terminated buffer as an input to `load_buffer_inplace` - i.e. `doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment)`.]
-
-These flags control the transformation of tree element contents:
-
-* [anchor parse_escapes] determines if character and entity references are to be expanded during the parsing process. Character references have the form [^&#...;] or [^&#x...;] ([^...] is Unicode numeric representation of character in either decimal ([^&#...;]) or hexadecimal ([^&#x...;]) form), entity references are [^&lt;], [^&gt;], [^&amp;], [^&apos;] and [^&quot;] (note that as pugixml does not handle DTD, the only allowed entities are predefined ones). If character/entity reference can not be expanded, it is left as is, so you can do additional processing later. Reference expansion is performed on attribute values and PCDATA content. This flag is *on* by default.
-[lbr]
-
-* [anchor parse_eol] determines if EOL handling (that is, replacing sequences `0x0d 0x0a` by a single `0x0a` character, and replacing all standalone `0x0d` characters by `0x0a`) is to be performed on input data (that is, comments contents, PCDATA/CDATA contents and attribute values). This flag is *on* by default.
-[lbr]
-
-* [anchor parse_wconv_attribute] determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (`' '`). New line characters are always treated as if [link parse_eol] is set, i.e. `\r\n` is converted to a single space. This flag is *on* by default.
-[lbr]
-
-* [anchor parse_wnorm_attribute] determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if [link parse_wconv_attribute] was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. [link parse_wconv_attribute] has no effect if this flag is on. This flag is *off* by default.
-
-[note `parse_wconv_attribute` option performs transformations that are required by W3C specification for attributes that are declared as [^CDATA]; [link parse_wnorm_attribute] performs transformations required for [^NMTOKENS] attributes. In the absence of document type declaration all attributes should behave as if they are declared as [^CDATA], thus [link parse_wconv_attribute] is the default option.]
-
-Additionally there are three predefined option masks:
-
-* [anchor parse_minimal] has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice [link parse_default] is usually equally fast.
-[lbr]
-
-* [anchor parse_default] is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons.
-[lbr]
-
-* [anchor parse_full] is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode.
-
-This is an example of using different parsing options ([@samples/load_options.cpp]):
-
-[import samples/load_options.cpp]
-[code_load_options]
-
-[endsect] [/options]
-
-[section:encoding Encodings]
-
-[#xml_encoding]
-pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions. Most loading functions accept the optional parameter `encoding`. This is a value of enumeration type `xml_encoding`, that can have the following values:
-
-* [anchor encoding_auto] means that pugixml will try to guess the encoding based on source XML data. The algorithm is a modified version of the one presented in Appendix F.1 of XML recommendation; it tries to match the first few bytes of input data with the following patterns in strict order:
-[lbr]
- * If first four bytes match UTF-32 BOM (Byte Order Mark), encoding is assumed to be UTF-32 with the endianness equal to that of BOM;
- * If first two bytes match UTF-16 BOM, encoding is assumed to be UTF-16 with the endianness equal to that of BOM;
- * If first three bytes match UTF-8 BOM, encoding is assumed to be UTF-8;
- * If first four bytes match UTF-32 representation of [^<], encoding is assumed to be UTF-32 with the corresponding endianness;
- * If first four bytes match UTF-16 representation of [^<?], encoding is assumed to be UTF-16 with the corresponding endianness;
- * If first two bytes match UTF-16 representation of [^<], encoding is assumed to be UTF-16 with the corresponding endianness (this guess may yield incorrect result, but it's better than UTF-8);
- * Otherwise encoding is assumed to be UTF-8.
- [lbr]
-
-* [anchor encoding_utf8] corresponds to UTF-8 encoding as defined in the Unicode standard; UTF-8 sequences with length equal to 5 or 6 are not standard and are rejected.
-* [anchor encoding_utf16_le] corresponds to little-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
-* [anchor encoding_utf16_be] corresponds to big-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.
-* [anchor encoding_utf16] corresponds to UTF-16 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
-* [anchor encoding_utf32_le] corresponds to little-endian UTF-32 encoding as defined in the Unicode standard.
-* [anchor encoding_utf32_be] corresponds to big-endian UTF-32 encoding as defined in the Unicode standard.
-* [anchor encoding_utf32] corresponds to UTF-32 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.
-* [anchor encoding_wchar] corresponds to the encoding of `wchar_t` type; it has the same meaning as either `encoding_utf16` or `encoding_utf32`, depending on `wchar_t` size.
-* [anchor encoding_latin1] corresponds to ISO-8859-1 encoding (also known as Latin-1).
-
-The algorithm used for `encoding_auto` correctly detects any supported Unicode encoding for all well-formed XML documents (since they start with document declaration) and for all other XML documents that start with [^<]; if your XML document does not start with [^<] and has encoding that is different from UTF-8, use the specific encoding.
-
-[note The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; moreover, in case no encoding conversion is performed, the invalid sequences are not removed, so you'll get them as is in node/attribute contents.]
-
-[endsect] [/encoding]
-
-[section:w3c Conformance to W3C specification]
-
-pugixml is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons.
-
-There is only one non-conformant behavior when dealing with valid XML documents: pugixml does not use information supplied in document type declaration for parsing. This means that entities declared in DOCTYPE are not expanded, and all attribute/PCDATA values are always processed in a uniform way that depends only on parsing options.
-
-As for rejecting invalid XML documents, there are a number of incompatibilities with W3C specification, including:
-
-* Multiple attributes of the same node can have equal names.
-* All non-ASCII characters are treated in the same way as symbols of English alphabet, so some invalid tag names are not rejected.
-* Attribute values which contain [^<] are not rejected.
-* Invalid entity/character references are not rejected and are instead left as is.
-* Comment values can contain [^--].
-* XML data is not required to begin with document declaration; additionally, document declaration can appear after comments and other nodes.
-* Invalid document type declarations are silently ignored in some cases.
-
-[endsect] [/w3c]
-
-[endsect] [/loading]
-
-[section:access Accessing document data]
-
-pugixml features an extensive interface for getting various types of data from the document and for traversing the document. This section provides documentation for all such functions that do not modify the tree except for XPath-related functions; see [sref manual.xpath] for XPath reference. As discussed in [sref manual.dom.cpp], there are two types of handles to tree data - [link xml_node] and [link xml_attribute]. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see [link node_null this description] for details. The documentation in this section will explicitly state the results of all function in case of null inputs.
-
-[import samples/traverse_base.cpp]
-
-[section:basic Basic traversal functions]
-
-[#xml_node::parent][#xml_node::first_child][#xml_node::last_child][#xml_node::next_sibling][#xml_node::previous_sibling][#xml_node::first_attribute][#xml_node::last_attribute][#xml_attribute::next_attribute][#xml_attribute::previous_attribute]
-The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).
-
- xml_node xml_node::parent() const;
- xml_node xml_node::first_child() const;
- xml_node xml_node::last_child() const;
- xml_node xml_node::next_sibling() const;
- xml_node xml_node::previous_sibling() const;
-
- xml_attribute xml_node::first_attribute() const;
- xml_attribute xml_node::last_attribute() const;
- xml_attribute xml_attribute::next_attribute() const;
- xml_attribute xml_attribute::previous_attribute() const;
-
-`parent` function returns the node's parent; all non-null nodes except the document have non-null parent. `first_child` and `last_child` return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. `next_sibling` and `previous_sibling` return the node that's immediately to the right\/left of this node in the children list, respectively - for example, in `<a/><b/><c/>`, calling `next_sibling` for a handle that points to `<b/>` results in a handle pointing to `<c/>`, and calling `previous_sibling` results in handle pointing to `<a/>`. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. `first_attribute`, `last_attribute`, `next_attribute` and `previous_attribute` functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way.
-
-[note Because of memory consumption reasons, attributes do not have a link to their parent nodes. Thus there is no `xml_attribute::parent()` function.]
-
-Calling any of the functions above on the null handle results in a null handle - i.e. `node.first_child().next_sibling()` returns the second child of `node`, and null handle if `node` is null, has no children at all or if it has only one child node.
-
-With these functions, you can iterate through all child nodes and display all attributes like this ([@samples/traverse_base.cpp]):
-
-[code_traverse_base_basic]
-
-[endsect] [/basic]
-
-[section:nodedata Getting node data]
-
-[#xml_node::name][#xml_node::value]
-Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. [link node_document] nodes do not have a name or value, [link node_element] and [link node_declaration] nodes always have a name but never have a value, [link node_pcdata], [link node_cdata], [link node_comment] and [link node_doctype] nodes never have a name but always have a value (it may be empty though), [link node_pi] nodes always have a name and a value (again, value may be empty). In order to get node's name or value, you can use the following functions:
-
- const char_t* xml_node::name() const;
- const char_t* xml_node::value() const;
-
-In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers.
-
-[#xml_node::child_value]
-It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type [link node_pcdata] with value `"This is a node"`. pugixml provides several helper functions to parse such data:
-
- const char_t* xml_node::child_value() const;
- const char_t* xml_node::child_value(const char_t* name) const;
- xml_text xml_node::text() const;
-
-`child_value()` returns the value of the first child with type [link node_pcdata] or [link node_cdata]; `child_value(name)` is a simple wrapper for `child(name).child_value()`. For the above example, calling `node.child_value("description")` and `description.child_value()` will both produce string `"This is a node"`. If there is no child with relevant type, or if the handle is null, `child_value` functions return empty string.
-
-`text()` returns a special object that can be used for working with PCDATA contents in more complex cases than just retrieving the value; it is described in [sref manual.access.text] sections.
-
-There is an example of using some of these functions [link code_traverse_base_data at the end of the next section].
-
-[endsect] [/nodedata]
-
-[section:attrdata Getting attribute data]
-
-[#xml_attribute::name][#xml_attribute::value]
-All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for `xml_node`:
-
- const char_t* xml_attribute::name() const;
- const char_t* xml_attribute::value() const;
-
-In case the attribute handle is null, both functions return empty strings - they never return null pointers.
-
-[#xml_attribute::as_string]
-If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to `"sorted"` instead of `""`), you can use `as_string` accessor:
-
- const char_t* xml_attribute::as_string(const char_t* def = "") const;
-
-It returns `def` argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to `value()`.
-
-[#xml_attribute::as_int][#xml_attribute::as_uint][#xml_attribute::as_double][#xml_attribute::as_float][#xml_attribute::as_bool][#xml_attribute::as_llong][#xml_attribute::as_ullong]
-In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:
-
- int xml_attribute::as_int(int def = 0) const;
- unsigned int xml_attribute::as_uint(unsigned int def = 0) const;
- double xml_attribute::as_double(double def = 0) const;
- float xml_attribute::as_float(float def = 0) const;
- bool xml_attribute::as_bool(bool def = false) const;
- long long xml_attribute::as_llong(long long def = 0) const;
- unsigned long long xml_attribute::as_ullong(unsigned long long def = 0) const;
-
-`as_int`, `as_uint`, `as_llong`, `as_ullong`, `as_double` and `as_float` convert attribute values to numbers. If attribute handle is null or attribute value is empty, `def` argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to `as_int`, `as_uint`, `as_llong` and `as_ullong`; hexadecimal format is used if the number has `0x` or `0X` prefix) or as a floating point number in either decimal or scientific form (`as_double` or `as_float`). Any extra characters are silently discarded, i.e. `as_int` will return `1` for string `"1abc"`.
-
-In case the input string contains a number that is out of the target numeric range, the result is undefined.
-
-[caution Number conversion functions depend on current C locale as set with `setlocale`, so may return unexpected results if the locale is different from `"C"`.]
-
-`as_bool` converts attribute value to boolean as follows: if attribute handle is null, `def` argument is returned (which is `false` by default). If attribute value is empty, `false` is returned. Otherwise, `true` is returned if the first character is one of `'1', 't', 'T', 'y', 'Y'`. This means that strings like `"true"` and `"yes"` are recognized as `true`, while strings like `"false"` and `"no"` are recognized as `false`. For more complex matching you'll have to write your own function.
-
-[note `as_llong` and `as_ullong` are only available if your platform has reliable support for the `long long` type, including string conversions.]
-
-[#code_traverse_base_data]
-This is an example of using these functions, along with node data retrieval ones ([@samples/traverse_base.cpp]):
-
-[code_traverse_base_data]
-
-[endsect] [/attrdata]
-
-[section:contents Contents-based traversal functions]
-
-[#xml_node::child][#xml_node::attribute][#xml_node::next_sibling_name][#xml_node::previous_sibling_name]
-Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:
-
- xml_node xml_node::child(const char_t* name) const;
- xml_attribute xml_node::attribute(const char_t* name) const;
- xml_node xml_node::next_sibling(const char_t* name) const;
- xml_node xml_node::previous_sibling(const char_t* name) const;
-
-`child` and `attribute` return the first child/attribute with the specified name; `next_sibling` and `previous_sibling` return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node\/attribute with the specified name, null handle is returned.
-
-`child` and `next_sibling` functions can be used together to loop through all child nodes with the desired name like this:
-
- for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
-
-[#xml_node::find_child_by_attribute]
-Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: `<group><item id="1"/> <item id="2"/></group>`. There are two functions for finding child nodes based on the attribute values:
-
- xml_node xml_node::find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
- xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
-
-The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive.
-
-In all of the above functions, all arguments have to be valid strings; passing null pointers results in undefined behavior.
-
-This is an example of using these functions ([@samples/traverse_base.cpp]):
-
-[code_traverse_base_contents]
-
-[endsect] [/contents]
-
-[section:rangefor Range-based for-loop support]
-
-[#xml_node::children][#xml_node::attributes]
-If your C++ compiler supports range-based for-loop (this is a C++11 feature, at the time of writing it's supported by Microsoft Visual Studio 11 Beta, GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with [@http://www.boost.org/libs/foreach/ Boost Foreach], and possibly other pre-C++11 foreach facilities.
-
- ``/implementation-defined type/`` xml_node::children() const;
- ``/implementation-defined type/`` xml_node::children(const char_t* name) const;
- ``/implementation-defined type/`` xml_node::attributes() const;
-
-`children` function allows you to enumerate all child nodes; `children` function with `name` argument allows you to enumerate all child nodes with a specific name; `attributes` function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using `children()`.
-
-This is an example of using these functions ([@samples/traverse_rangefor.cpp]):
-
-[import samples/traverse_rangefor.cpp]
-[code_traverse_rangefor]
-
-[endsect] [/rangefor]
-
-[section:iterators Traversing node/attribute lists via iterators]
-
-[#xml_node_iterator][#xml_attribute_iterator][#xml_node::begin][#xml_node::end][#xml_node::attributes_begin][#xml_node::attributes_end]
-Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes:
-
- class xml_node_iterator;
- class xml_attribute_iterator;
-
- typedef xml_node_iterator xml_node::iterator;
- iterator xml_node::begin() const;
- iterator xml_node::end() const;
-
- typedef xml_attribute_iterator xml_node::attribute_iterator;
- attribute_iterator xml_node::attributes_begin() const;
- attribute_iterator xml_node::attributes_end() const;
-
-`begin` and `attributes_begin` return iterators that point to the first node\/attribute, respectively; `end` and `attributes_end` return past-the-end iterator for node\/attribute list, respectively - this iterator can't be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: `xml_node_iterator(node)`. For `xml_attribute_iterator`, you'll have to provide both an attribute and its parent node.
-
-`begin` and `end` return equal iterators if called on null node; such iterators can't be dereferenced. `attributes_begin` and `attributes_end` behave the same way. For correct iterator usage this means that child node\/attribute collections of null nodes appear to be empty.
-
-Both types of iterators have bidirectional iterator semantics (i.e. they can be incremented and decremented, but efficient random access is not supported) and support all usual iterator operations - comparison, dereference, etc. The iterators are invalidated if the node\/attribute objects they're pointing to are removed from the tree; adding nodes\/attributes does not invalidate any iterators.
-
-Here is an example of using iterators for document traversal ([@samples/traverse_iter.cpp]):
-
-[import samples/traverse_iter.cpp]
-[code_traverse_iter]
-
-[caution Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference by assignment - i.e. passing iterators to a function like `std::sort` - will not give expected results, as assignment modifies local handle that's stored in the iterator.]
-
-[endsect] [/iterators]
-
-[section:walker Recursive traversal with xml_tree_walker]
-
-[#xml_tree_walker]
-The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you'll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement `xml_tree_walker` interface and to call `traverse` function:
-
- class xml_tree_walker
- {
- public:
- virtual bool begin(xml_node& node);
- virtual bool for_each(xml_node& node) = 0;
- virtual bool end(xml_node& node);
-
- int depth() const;
- };
-
- bool xml_node::traverse(xml_tree_walker& walker);
-
-[#xml_tree_walker::begin][#xml_tree_walker::for_each][#xml_tree_walker::end][#xml_node::traverse]
-The traversal is launched by calling `traverse` function on traversal root and proceeds as follows:
-
-* First, `begin` function is called with traversal root as its argument.
-* Then, `for_each` function is called for all nodes in the traversal subtree in depth first order, excluding the traversal root. Node is passed as an argument.
-* Finally, `end` function is called with traversal root as its argument.
-
-If `begin`, `end` or any of the `for_each` calls return `false`, the traversal is terminated and `false` is returned as the traversal result; otherwise, the traversal results in `true`. Note that you don't have to override `begin` or `end` functions; their default implementations return `true`.
-
-[#xml_tree_walker::depth]
-You can get the node's depth relative to the traversal root at any point by calling `depth` function. It returns `-1` if called from `begin`\/`end`, and returns 0-based depth if called from `for_each` - depth is 0 for all children of the traversal root, 1 for all grandchildren and so on.
-
-This is an example of traversing tree hierarchy with xml_tree_walker ([@samples/traverse_walker.cpp]):
-
-[import samples/traverse_walker.cpp]
-[code_traverse_walker_impl]
-[code_traverse_walker_traverse]
-
-[endsect] [/walker]
-
-[section:predicate Searching for nodes/attributes with predicates]
-
-[#xml_node::find_attribute][#xml_node::find_child][#xml_node::find_node]
-While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of `find_` functions:
-
- template <typename Predicate> xml_attribute xml_node::find_attribute(Predicate pred) const;
- template <typename Predicate> xml_node xml_node::find_child(Predicate pred) const;
- template <typename Predicate> xml_node xml_node::find_node(Predicate pred) const;
-
-The predicate should be either a plain function or a function object which accepts one argument of type `xml_attribute` (for `find_attribute`) or `xml_node` (for `find_child` and `find_node`), and returns `bool`. The predicate is never called with null handle as an argument.
-
-`find_attribute` function iterates through all attributes of the specified node, and returns the first attribute for which the predicate returned `true`. If the predicate returned `false` for all attributes or if there were no attributes (including the case where the node is null), null attribute is returned.
-
-`find_child` function iterates through all child nodes of the specified node, and returns the first node for which the predicate returned `true`. If the predicate returned `false` for all nodes or if there were no child nodes (including the case where the node is null), null node is returned.
-
-`find_node` function performs a depth-first traversal through the subtree of the specified node (excluding the node itself), and returns the first node for which the predicate returned `true`. If the predicate returned `false` for all nodes or if subtree was empty, null node is returned.
-
-This is an example of using predicate-based functions ([@samples/traverse_predicate.cpp]):
-
-[import samples/traverse_predicate.cpp]
-[code_traverse_predicate_decl]
-[code_traverse_predicate_find]
-
-[endsect] [/predicate]
-
-[section:text Working with text contents]
-
-[#xml_text]
-It is common to store data as text contents of some node - i.e. `<node><description>This is a node</description></node>`. In this case, `<description>` node does not have a value, but instead has a child of type [link node_pcdata] with value `"This is a node"`. pugixml provides a special class, `xml_text`, to work with such data. Working with text objects to modify data is described in [link manual.modify.text the documentation for modifying document data]; this section describes the access interface of `xml_text`.
-
-[#xml_node::text]
-You can get the text object from a node by using `text()` method:
-
- xml_text xml_node::text() const;
-
-If the node has a type `node_pcdata` or `node_cdata`, then the node itself is used to return data; otherwise, a first child node of type `node_pcdata` or `node_cdata` is used.
-
-[#xml_text::empty]
-[#xml_text::unspecified_bool_type]
-You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. `if (text) { ... }` or `if (!text) { ... }`. Alternatively you can check it by using the `empty()` method:
-
- bool xml_text::empty() const;
-
-[#xml_text::get]
-Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:
-
- const char_t* xml_text::get() const;
-
-In case text object is empty, the function returns an empty string - it never returns a null pointer.
-
-[#xml_text::as_string][#xml_text::as_int][#xml_text::as_uint][#xml_text::as_double][#xml_text::as_float][#xml_text::as_bool][#xml_text::as_llong][#xml_text::as_ullong]
-If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors:
-
- const char_t* xml_text::as_string(const char_t* def = "") const;
- int xml_text::as_int(int def = 0) const;
- unsigned int xml_text::as_uint(unsigned int def = 0) const;
- double xml_text::as_double(double def = 0) const;
- float xml_text::as_float(float def = 0) const;
- bool xml_text::as_bool(bool def = false) const;
- long long xml_text::as_llong(long long def = 0) const;
- unsigned long long xml_text::as_ullong(unsigned long long def = 0) const;
-
-All of the above functions have the same semantics as similar `xml_attribute` members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can [link xml_attribute::as_int refer to documentation for the attribute functions] for details.
-
-[#xml_text::data]
-`xml_text` is essentially a helper class that operates on `xml_node` values. It is bound to a node of type [link node_pcdata] or [link node_cdata]. You can use the following function to retrieve this node:
-
- xml_node xml_text::data() const;
-
-Essentially, assuming `text` is an `xml_text` object, calling `text.get()` is equivalent to calling `text.data().value()`.
-
-This is an example of using `xml_text` object ([@samples/text.cpp]):
-
-[import samples/text.cpp]
-[code_text_access]
-
-[endsect] [/text]
-
-[section:misc Miscellaneous functions]
-
-[#xml_node::root]
-If you need to get the document root of some node, you can use the following function:
-
- xml_node xml_node::root() const;
-
-This function returns the node with type [link node_document], which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).
-
-[#xml_node::path]
-[#xml_node::first_element_by_path]
-While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node:
-
- string_t xml_node::path(char_t delimiter = '/') const;
- xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const;
-
-Node paths consist of node names, separated with a delimiter (which is `/` by default); also paths can contain self (`.`) and parent (`..`) pseudo-names, so that this is a valid path: `"../../foo/./bar"`. `path` returns the path to the node from the document root, `first_element_by_path` looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: `<a><b><c/></b></a>`, node `<c/>` has path `"a/b/c"`; calling `first_element_by_path` for document with path `"a/b"` results in node `<b/>`; calling `first_element_by_path` for node `<a/>` with path `"../a/./b/../."` results in node `<a/>`; calling `first_element_by_path` with path `"/a"` results in node `<a/>` for any node.
-
-In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of `first_element_by_path` is null node; also `first_element_by_path` returns null node for null nodes, in which case the path does not matter. `path` returns an empty string for null nodes.
-
-[note `path` function returns the result as STL string, and thus is not available if [link PUGIXML_NO_STL] is defined.]
-
-[#xml_node::offset_debug]
-pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer:
-
- ptrdiff_t xml_node::offset_debug() const;
-
-If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node's data from the beginning of XML buffer in [link char_t pugi::char_t] units. For more information on parsing offsets, see [link xml_parse_result::offset parsing error handling documentation].
-
-[endsect] [/misc]
-
-[endsect] [/access]
-
-[section:modify Modifying document data]
-
-The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. This section provides documentation for the relevant functions. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.
-
-All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: `void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }`, so const-correctness here mainly provides additional documentation.
-
-[import samples/modify_base.cpp]
-
-[section:nodedata Setting node data]
-
-[#xml_node::set_name][#xml_node::set_value]
-As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. [link node_document] nodes do not have a name or value, [link node_element] and [link node_declaration] nodes always have a name but never have a value, [link node_pcdata], [link node_cdata], [link node_comment] and [link node_doctype] nodes never have a name but always have a value (it may be empty though), [link node_pi] nodes always have a name and a value (again, value may be empty). In order to set node's name or value, you can use the following functions:
-
- bool xml_node::set_name(const char_t* rhs);
- bool xml_node::set_value(const char_t* rhs);
-
-Both functions try to set the name\/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call `set_name` on a [link node_pcdata] node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.
-
-There is no equivalent of [link xml_node::child_value child_value] function for modifying text children of the node.
-
-This is an example of setting node name and value ([@samples/modify_base.cpp]):
-
-[code_modify_base_node]
-
-[endsect] [/nodedata]
-
-[section:attrdata Setting attribute data]
-
-[#xml_attribute::set_name][#xml_attribute::set_value]
-All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:
-
- bool xml_attribute::set_name(const char_t* rhs);
- bool xml_attribute::set_value(const char_t* rhs);
-
-Both functions try to set the name\/value to the specified string, and return the operation result. The operation fails if the attribute handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.
-
-In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values:
-
- bool xml_attribute::set_value(int rhs);
- bool xml_attribute::set_value(unsigned int rhs);
- bool xml_attribute::set_value(double rhs);
- bool xml_attribute::set_value(float rhs);
- bool xml_attribute::set_value(bool rhs);
- bool xml_attribute::set_value(long long rhs);
- bool xml_attribute::set_value(unsigned long long rhs);
-
-The above functions convert the argument to string and then call the base `set_value` function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either `"true"` or `"false"`.
-
-[caution Number conversion functions depend on current C locale as set with `setlocale`, so may generate unexpected results if the locale is different from `"C"`.]
-
-[note `set_value` overloads with `long long` type are only available if your platform has reliable support for the type, including string conversions.]
-
-[#xml_attribute::assign]
-
-For convenience, all `set_value` functions have the corresponding assignment operators:
-
- xml_attribute& xml_attribute::operator=(const char_t* rhs);
- xml_attribute& xml_attribute::operator=(int rhs);
- xml_attribute& xml_attribute::operator=(unsigned int rhs);
- xml_attribute& xml_attribute::operator=(double rhs);
- xml_attribute& xml_attribute::operator=(float rhs);
- xml_attribute& xml_attribute::operator=(bool rhs);
- xml_attribute& xml_attribute::operator=(long long rhs);
- xml_attribute& xml_attribute::operator=(unsigned long long rhs);
-
-These operators simply call the right `set_value` function and return the attribute they're called on; the return value of `set_value` is ignored, so errors are ignored.
-
-This is an example of setting attribute name and value ([@samples/modify_base.cpp]):
-
-[code_modify_base_attr]
-
-[endsect] [/attrdata]
-
-[section:add Adding nodes/attributes]
-
-[#xml_node::prepend_attribute][#xml_node::append_attribute][#xml_node::insert_attribute_after][#xml_node::insert_attribute_before][#xml_node::prepend_child][#xml_node::append_child][#xml_node::insert_child_after][#xml_node::insert_child_before]
-Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before\/after some other node:
-
- xml_attribute xml_node::append_attribute(const char_t* name);
- xml_attribute xml_node::prepend_attribute(const char_t* name);
- xml_attribute xml_node::insert_attribute_after(const char_t* name, const xml_attribute& attr);
- xml_attribute xml_node::insert_attribute_before(const char_t* name, const xml_attribute& attr);
-
- xml_node xml_node::append_child(xml_node_type type = node_element);
- xml_node xml_node::prepend_child(xml_node_type type = node_element);
- xml_node xml_node::insert_child_after(xml_node_type type, const xml_node& node);
- xml_node xml_node::insert_child_before(xml_node_type type, const xml_node& node);
-
- xml_node xml_node::append_child(const char_t* name);
- xml_node xml_node::prepend_child(const char_t* name);
- xml_node xml_node::insert_child_after(const char_t* name, const xml_node& node);
- xml_node xml_node::insert_child_before(const char_t* name, const xml_node& node);
-
-`append_attribute` and `append_child` create a new node\/attribute at the end of the corresponding list of the node the method is called on; `prepend_attribute` and `prepend_child` create a new node\/attribute at the beginning of the list; `insert_attribute_after`, `insert_attribute_before`, `insert_child_after` and `insert_attribute_before` add the node\/attribute before or after the specified node\/attribute.
-
-Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the `type` argument create the node with the specified type; since node type can't be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the `name` argument create the element node ([link node_element]) with the specified name.
-
-All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure:
-
-* Adding fails if the target node is null;
-* Only [link node_element] nodes can contain attributes, so attribute adding fails if node is not an element;
-* Only [link node_document] and [link node_element] nodes can contain children, so child node adding fails if the target node is not an element or a document;
-* [link node_document] and [link node_null] nodes can not be inserted as children, so passing [link node_document] or [link node_null] value as `type` results in operation failure;
-* [link node_declaration] nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails;
-* Adding node/attribute results in memory allocation, which may fail;
-* Insertion functions fail if the specified node or attribute is null or is not in the target node's children/attribute list.
-
-Even if the operation fails, the document remains in consistent state, but the requested node/attribute is not added.
-
-[caution attribute() and child() functions do not add attributes or nodes to the tree, so code like `node.attribute("id") = 123;` will not do anything if `node` does not have an attribute with name `"id"`. Make sure you're operating with existing attributes/nodes by adding them if necessary.]
-
-This is an example of adding new attributes\/nodes to the document ([@samples/modify_add.cpp]):
-
-[import samples/modify_add.cpp]
-[code_modify_add]
-
-[endsect] [/add]
-
-[section:remove Removing nodes/attributes]
-
-[#xml_node::remove_attribute][#xml_node::remove_child]
-If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:
-
- bool xml_node::remove_attribute(const xml_attribute& a);
- bool xml_node::remove_child(const xml_node& n);
-
-`remove_attribute` removes the attribute from the attribute list of the node, and returns the operation result. `remove_child` removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. Removing fails if one of the following is true:
-
-* The node the function is called on is null;
-* The attribute\/node to be removed is null;
-* The attribute\/node to be removed is not in the node's attribute\/child list.
-
-Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute\/node is removed.
-
-If you want to remove the attribute or child node by its name, two additional helper functions are available:
-
- bool xml_node::remove_attribute(const char_t* name);
- bool xml_node::remove_child(const char_t* name);
-
-These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns `false`; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: `while (node.remove_child("tool")) ;`.
-
-This is an example of removing attributes\/nodes from the document ([@samples/modify_remove.cpp]):
-
-[import samples/modify_remove.cpp]
-[code_modify_remove]
-
-[endsect] [/remove]
-
-[section:text Working with text contents]
-
-pugixml provides a special class, `xml_text`, to work with text contents stored as a value of some node, i.e. `<node><description>This is a node</description></node>`. Working with text objects to retrieve data is described in [link manual.access.text the documentation for accessing document data]; this section describes the modification interface of `xml_text`.
-
-[#xml_text::set]
-Once you have an `xml_text` object, you can set the text contents using the following function:
-
- bool xml_text::set(const char_t* rhs);
-
-This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a [link node_declaration] node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from an element node, this function creates the PCDATA child node if necessary (i.e. if the element node does not have a PCDATA/CDATA child already).
-
-[#xml_text::set_value]
-In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:
-
- bool xml_text::set(int rhs);
- bool xml_text::set(unsigned int rhs);
- bool xml_text::set(double rhs);
- bool xml_text::set(float rhs);
- bool xml_text::set(bool rhs);
- bool xml_text::set(long long rhs);
- bool xml_text::set(unsigned long long rhs);
-
-The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can [link xml_attribute::set_value refer to documentation for the attribute functions] for details.
-
-[#xml_text::assign]
-
-For convenience, all `set` functions have the corresponding assignment operators:
-
- xml_text& xml_text::operator=(const char_t* rhs);
- xml_text& xml_text::operator=(int rhs);
- xml_text& xml_text::operator=(unsigned int rhs);
- xml_text& xml_text::operator=(double rhs);
- xml_text& xml_text::operator=(float rhs);
- xml_text& xml_text::operator=(bool rhs);
- xml_text& xml_text::operator=(long long rhs);
- xml_text& xml_text::operator=(unsigned long long rhs);
-
-These operators simply call the right `set` function and return the attribute they're called on; the return value of `set` is ignored, so errors are ignored.
-
-This is an example of using `xml_text` object to modify text contents ([@samples/text.cpp]):
-
-[code_text_modify]
-
-[endsect] [/text]
-
-[section:clone Cloning nodes/attributes]
-
-[#xml_node::prepend_copy][#xml_node::append_copy][#xml_node::insert_copy_after][#xml_node::insert_copy_before]
-With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can't create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions:
-
- xml_attribute xml_node::append_copy(const xml_attribute& proto);
- xml_attribute xml_node::prepend_copy(const xml_attribute& proto);
- xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
- xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
-
- xml_node xml_node::append_copy(const xml_node& proto);
- xml_node xml_node::prepend_copy(const xml_node& proto);
- xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node);
- xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node);
-
-These functions mirror the structure of `append_child`, `prepend_child`, `insert_child_before` and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute\/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure.
-
-The attribute is copied along with the name and value; the node is copied along with its type, name and value; additionally attribute list and all children are recursively cloned, resulting in the deep subtree clone. The prototype object can be a part of the same document, or a part of any other document.
-
-The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, [link xml_node::append_child consult their documentation for more information]. There are additional caveats specific to cloning functions:
-
-* Cloning null handles results in operation failure;
-* Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since [link node_document] is not a valid insertion type. The example below provides a workaround.
-* It is possible to copy a subtree as a child of some node inside this subtree, i.e. `node.append_copy(node.parent().parent());`. This is a valid operation, and it results in a clone of the subtree in the state before cloning started, i.e. no infinite recursion takes place.
-
-This is an example with one possible implementation of include tags in XML ([@samples/include.cpp]). It illustrates node cloning and usage of other document modification functions:
-
-[import samples/include.cpp]
-[code_include]
-
-[endsect] [/clone]
-
-[section:move Moving nodes]
-
-[#xml_node::prepend_move][#xml_node::append_move][#xml_node::insert_move_after][#xml_node::insert_move_before]
-Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:
-
- xml_node xml_node::append_move(const xml_node& moved);
- xml_node xml_node::prepend_move(const xml_node& moved);
- xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node);
- xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node);
-
-These functions mirror the structure of `append_copy`, `prepend_copy`, `insert_copy_before` and `insert_copy_after` - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.
-
-The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, [link xml_node::append_child consult their documentation for more information]. There are additional caveats specific to moving functions:
-
-* Moving null handles results in operation failure;
-* Moving is only possible for nodes that belong to the same document; attempting to move nodes between documents will fail.
-* `insert_move_after` and `insert_move_before` functions fail if the moved node is the same as the `node` argument (this operation would be a no-op otherwise).
-* It is impossible to move a subtree to a child of some node inside this subtree, i.e. `node.append_move(node.parent().parent());` will fail.
-
-[endsect] [/move]
-
-[section:fragments Assembling document from fragments]
-
-[#xml_node::append_buffer]
-pugixml provides several ways to assemble an XML document from other XML documents. Assuming there is a set of document fragments, represented as in-memory buffers, the implementation choices are as follows:
-
-* Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:
-
- bool append_fragment(pugi::xml_node target, const char* buffer, size_t size)
- {
- pugi::xml_document doc;
- if (!doc.load_buffer(buffer, size)) return false;
-
- for (pugi::xml_node child = doc.first_child(); child; child = child.next_sibling())
- target.append_copy(child);
- }
-
-* Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment:
-
- bool append_fragment(pugi::xml_node target, const pugi::xml_document& cached_fragment)
- {
- for (pugi::xml_node child = cached_fragment.first_child(); child; child = child.next_sibling())
- target.append_copy(child);
- }
-
-* Use xml_node::append_buffer directly:
-
- xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-The first method is more convenient, but slower than the other two. The relative performance of `append_copy` and `append_buffer` depends on the buffer format - usually `append_buffer` is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending on `PUGIXML_WCHAR_MODE`). At the same time it might be less efficient in terms of memory usage - the implementation makes a copy of the provided buffer, and the copy has the same lifetime as the document - the memory used by that copy will be reclaimed after the document is destroyed, but no sooner. Even deleting all nodes in the document, including the appended ones, won't reclaim the memory.
-
-`append_buffer` behaves in the same way as [link xml_document::load_buffer] - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns.
-
-[#status_append_invalid_root]
-Since `append_buffer` needs to append child nodes to the current node, it only works if the current node is either document or element node. Calling `append_buffer` on a node with any other type results in an error with `status_append_invalid_root` status.
-
-[endsect] [/fragments]
-
-[endsect] [/modify]
-
-[section:saving Saving document]
-
-Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format (see [sref manual.saving.options]), and also perform necessary encoding conversions (see [sref manual.saving.encoding]). This section documents the relevant functionality.
-
-Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped (unless [link format_no_escapes] flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values.
-
-CDATA sections with values that contain `"]]>"` are split into several sections as follows: section with value `"pre]]>post"` is written as `<![CDATA[pre]]]]><![CDATA[>post]]>`. While this alters the structure of the document (if you load the document after saving it, there will be two CDATA sections instead of one), this is the only way to escape CDATA contents.
-
-[section:file Saving document to a file]
-
-[#xml_document::save_file]
-[#xml_document::save_file_wide]
-If you want to save the whole document to a file, you can use one of the following functions:
-
- bool xml_document::save_file(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
- bool xml_document::save_file(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-
-These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see [sref manual.saving.options]) and output data encoding (see [sref manual.saving.encoding]). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.
-
-File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.
-
-[#xml_writer_file]
-`save_file` opens the target file for writing, outputs the requested header (by default a document declaration is output, unless the document already has one), and then saves the document contents. If the file could not be opened, the function returns `false`. Calling `save_file` is equivalent to creating an `xml_writer_file` object with `FILE*` handle as the only constructor argument and then calling `save`; see [sref manual.saving.writer] for writer interface details.
-
-This is a simple example of saving XML document to file ([@samples/save_file.cpp]):
-
-[import samples/save_file.cpp]
-[code_save_file]
-
-[endsect] [/file]
-
-[section:stream Saving document to C++ IOstreams]
-
-[#xml_document::save_stream]
-To enhance interoperability pugixml provides functions for saving document to any object which implements C++ `std::ostream` interface. This allows you to save documents to any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:
-
- void xml_document::save(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
- void xml_document::save(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
-
-`save` with `std::ostream` argument saves the document to the stream in the same way as `save_file` (i.e. with requested header and with encoding conversions). On the other hand, `save` with `std::wstream` argument saves the document to the wide stream with [link encoding_wchar] encoding. Because of this, using `save` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale.
-
-[#xml_writer_stream]
-Calling `save` with stream target is equivalent to creating an `xml_writer_stream` object with stream as the only constructor argument and then calling `save`; see [sref manual.saving.writer] for writer interface details.
-
-This is a simple example of saving XML document to standard output ([@samples/save_stream.cpp]):
-
-[import samples/save_stream.cpp]
-[code_save_stream]
-
-[endsect] [/stream]
-
-[section:writer Saving document via writer interface]
-
-[#xml_document::save][#xml_writer][#xml_writer::write]
-All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input:
-
- class xml_writer
- {
- public:
- virtual void write(const void* data, size_t size) = 0;
- };
-
- void xml_document::save(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-
-In order to output the document via some custom transport, for example sockets, you should create an object which implements `xml_writer` interface and pass it to `save` function. `xml_writer::write` function is called with a buffer as an input, where `data` points to buffer start, and `size` is equal to the buffer size in bytes. `write` implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after `write` returns. The buffer contains the chunk of document data in the desired encoding.
-
-`write` function is called with relatively large blocks (size is usually several kilobytes, except for the last block that may be small), so there is often no need for additional buffering in the implementation.
-
-This is a simple example of custom writer for saving document data to STL string ([@samples/save_custom_writer.cpp]); read the sample code for more complex examples:
-
-[import samples/save_custom_writer.cpp]
-[code_save_custom_writer]
-
-[endsect] [/writer]
-
-[section:subtree Saving a single subtree]
-
-[#xml_node::print][#xml_node::print_stream]
-While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided:
-
- void xml_node::print(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
- void xml_node::print(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
- void xml_node::print(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
-
-These functions have the same arguments with the same meaning as the corresponding `xml_document::save` functions, and allow you to save the subtree to either a C++ IOstream or to any object that implements `xml_writer` interface.
-
-Saving a subtree differs from saving the whole document: the process behaves as if [link format_write_bom] is off, and [link format_no_declaration] is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node's children. Note that this also holds if you're saving a document; this example ([@samples/save_subtree.cpp]) illustrates the difference:
-
-[import samples/save_subtree.cpp]
-[code_save_subtree]
-
-[endsect] [/subtree]
-
-[section:options Output options]
-
-All saving functions accept the optional parameter `flags`. This is a bitmask that customizes the output format; you can select the way the document nodes are printed and select the needed additional information that is output before the document contents.
-
-[note You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use `mask | flag`; to disable a flag, use `mask & ~flag`.]
-
-These flags control the resulting tree contents:
-
-* [anchor format_indent] determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is `"\t"` by default). If this flag is on, before every node the indentation string is output several times, where the amount of indentation depends on the node's depth relative to the output subtree. This flag has no effect if [link format_raw] is enabled. This flag is *on* by default.
-[lbr]
-
-* [anchor format_raw] switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with [link parse_ws_pcdata] flag, to preserve the original document formatting as much as possible. This flag is *off* by default.
-[lbr]
-
-* [anchor format_no_escapes] disables output escaping for attribute values and PCDATA contents. If this flag is off, special symbols (', &, <, >) and all non-printable characters (those with codepoint values less than 32) are converted to XML escape sequences (i.e. &amp;) during output. If this flag is on, no text processing is performed; therefore, output XML can be malformed if output contents contains invalid symbols (i.e. having a stray < in the PCDATA will make the output malformed). This flag is *off* by default.
-
-These flags control the additional output information:
-
-* [anchor format_no_declaration] disables default node declaration output. By default, if the document is saved via `save` or `save_file` function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in `xml_node::print` functions: they never output the default declaration. This flag is *off* by default.
-[lbr]
-
-* [anchor format_write_bom] enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document's encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in `xml_node::print` functions: they never output the BOM. This flag is *off* by default.
-
-* [anchor format_save_file_text] changes the file mode when using `save_file` function. By default, file is opened in binary mode, which means that the output file will
-contain platform-independent newline \\n (ASCII 10). If this flag is on, file is opened in text mode, which on some systems changes the newline format (i.e. on Windows you can use this flag to output XML documents with \\r\\n (ASCII 13 10) newlines. This flag is *off* by default.
-
-Additionally, there is one predefined option mask:
-
-* [anchor format_default] is the default set of flags, i.e. it has all options set to their default values. It sets formatted output with indentation, without BOM and with default node declaration, if necessary.
-
-This is an example that shows the outputs of different output options ([@samples/save_options.cpp]):
-
-[import samples/save_options.cpp]
-[code_save_options]
-
-[endsect] [/options]
-
-[section:encoding Encodings]
-
-pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions during output. The output encoding is set via the `encoding` parameter of saving functions, which is of type `xml_encoding`. The possible values for the encoding are documented in [sref manual.loading.encoding]; the only flag that has a different meaning is `encoding_auto`.
-
-While all other flags set the exact encoding, `encoding_auto` is meant for automatic encoding detection. The automatic detection does not make sense for output encoding, since there is usually nothing to infer the actual encoding from, so here `encoding_auto` means UTF-8 encoding, which is the most popular encoding for XML data storage. This is also the default value of output encoding; specify another value if you do not want UTF-8 encoded output.
-
-Also note that wide stream saving functions do not have `encoding` argument and always assume [link encoding_wchar] encoding.
-
-[note The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; if your node/attribute names do not contain any valid UTF sequences, they may be output as if they are empty, which will result in malformed XML document.]
-
-[endsect] [/encoding]
-
-[section:declaration Customizing document declaration]
-
-When you are saving the document using `xml_document::save()` or `xml_document::save_file()`, a default XML document declaration is output, if `format_no_declaration` is not specified and if the document does not have a declaration node. However, the default declaration is not customizable. If you want to customize the declaration output, you need to create the declaration node yourself.
-
-[note By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag [link parse_declaration] to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving.]
-
-Declaration node is a node with type [link node_declaration]; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values.
-
-This is an example that shows how to create a custom declaration node ([@samples/save_declaration.cpp]):
-
-[import samples/save_declaration.cpp]
-[code_save_declaration]
-
-[endsect] [/declaration]
-
-[endsect] [/saving]
-
-[section:xpath XPath]
-
-If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in [sref manual.xpath.w3c]. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read [@http://www.w3schools.com/xpath/ W3Schools XPath tutorial], [@http://www.tizag.com/xmlTutorial/xpathtutorial.php XPath tutorial at tizag.com], and [@http://www.w3.org/TR/xpath/ the XPath 1.0 specification].
-
-[section:types XPath types]
-
-[#xpath_value_type][#xpath_type_number][#xpath_type_string][#xpath_type_boolean][#xpath_type_node_set][#xpath_type_none]
-Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to `bool` type, number type corresponds to `double` type, string type corresponds to either `std::string` or `std::wstring`, depending on whether [link manual.dom.unicode wide character interface is enabled], and node set corresponds to [link xpath_node_set] type. There is an enumeration, `xpath_value_type`, which can take the values `xpath_type_boolean`, `xpath_type_number`, `xpath_type_string` or `xpath_type_node_set`, accordingly.
-
-[#xpath_node][#xpath_node::node][#xpath_node::attribute][#xpath_node::parent]
-Because an XPath node can be either a node or an attribute, there is a special type, `xpath_node`, which is a discriminated union of these types. A value of this type contains two node handles, one of `xml_node` type, and another one of `xml_attribute` type; at most one of them can be non-null. The accessors to get these handles are available:
-
- xml_node xpath_node::node() const;
- xml_attribute xpath_node::attribute() const;
-
-XPath nodes can be null, in which case both accessors return null handles.
-
-Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function:
-
- xml_node xpath_node::parent() const;
-
-`parent` function returns the node's parent if the XPath node corresponds to `xml_node` handle (equivalent to `node().parent()`), or the node to which the attribute belongs to, if the XPath node corresponds to `xml_attribute` handle. For null nodes, `parent` returns null handle.
-
-[#xpath_node::unspecified_bool_type][#xpath_node::comparison]
-Like node and attribute handles, XPath node handles can be implicitly cast to boolean-like object to check if it is a null node, and also can be compared for equality with each other.
-
-[#xpath_node::ctor]
-You can also create XPath nodes with one of the three constructors: the default constructor, the constructor that takes node argument, and the constructor that takes attribute and node arguments (in which case the attribute must belong to the attribute list of the node). The constructor from `xml_node` is implicit, so you can usually pass `xml_node` to functions that expect `xpath_node`. Apart from that you usually don't need to create your own XPath node objects, since they are returned to you via selection functions.
-
-[#xpath_node_set]
-XPath expressions operate not on single nodes, but instead on node sets. A node set is a collection of nodes, which can be optionally ordered in either a forward document order or a reverse one. Document order is defined in XPath specification; an XPath node is before another node in document order if it appears before it in XML representation of the corresponding document.
-
-[#xpath_node_set::const_iterator][#xpath_node_set::begin][#xpath_node_set::end]
-Node sets are represented by `xpath_node_set` object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors:
-
- typedef const xpath_node* xpath_node_set::const_iterator;
- const_iterator xpath_node_set::begin() const;
- const_iterator xpath_node_set::end() const;
-
-[#xpath_node_set::index][#xpath_node_set::size][#xpath_node_set::empty]
-And it also can be iterated via indices, just like `std::vector`:
-
- const xpath_node& xpath_node_set::operator[](size_t index) const;
- size_t xpath_node_set::size() const;
- bool xpath_node_set::empty() const;
-
-All of the above operations have the same semantics as that of `std::vector`: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster.
-
-[#xpath_node_set::type][#xpath_node_set::type_unsorted][#xpath_node_set::type_sorted][#xpath_node_set::type_sorted_reverse][#xpath_node_set::sort]
-The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:
-
- enum xpath_node_set::type_t {type_unsorted, type_sorted, type_sorted_reverse};
- type_t xpath_node_set::type() const;
-
-`type` function returns the current order of nodes; `type_sorted` means that the nodes are in forward document order, `type_sorted_reverse` means that the nodes are in reverse document order, and `type_unsorted` means that neither order is guaranteed (nodes can accidentally be in a sorted order even if `type()` returns `type_unsorted`). If you require a specific order of iteration, you can change it via `sort` function:
-
- void xpath_node_set::sort(bool reverse = false);
-
-Calling `sort` sorts the nodes in either forward or reverse document order, depending on the argument; after this call `type()` will return `type_sorted` or `type_sorted_reverse`.
-
-[#xpath_node_set::first]
-Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:
-
- xpath_node xpath_node_set::first() const;
-
-This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of `type()`), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.
-
-[#xpath_node_set::ctor]
-While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (`const_iterator` is a typedef for `const xpath_node*`), and an optional type:
-
- xpath_node_set::xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
-
-The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you'll have to ensure that the range contains no duplicates, and that the objects are sorted according to the `type` parameter. Otherwise XPath operations with this set may produce unexpected results.
-
-[endsect] [/types]
-
-[section:select Selecting nodes via XPath expression]
-
-[#xml_node::select_node][#xml_node::select_nodes]
-If you want to select nodes that match some XPath expression, you can do it with the following functions:
-
- xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const;
- xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
-
-`select_nodes` function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. `select_node` returns only the first node in document order from the result, and is equivalent to calling `select_nodes(query).first()`. If the XPath expression does not match anything, or the node handle is null, `select_nodes` returns an empty set, and `select_node` returns null XPath node.
-
-If exception handling is not disabled, both functions throw [link xpath_exception] if the query can not be compiled or if it returns a value with type other than node set; see [sref manual.xpath.errors] for details.
-
-[#xml_node::select_node_precomp][#xml_node::select_nodes_precomp]
-While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you're doing many similar queries, consider compiling them into query objects (see [sref manual.xpath.query] for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:
-
- xpath_node xml_node::select_node(const xpath_query& query) const;
- xpath_node_set xml_node::select_nodes(const xpath_query& query) const;
-
-If exception handling is not disabled, both functions throw [link xpath_exception] if the query returns a value with type other than node set.
-
-This is an example of selecting nodes using XPath expressions ([@samples/xpath_select.cpp]):
-
-[import samples/xpath_select.cpp]
-[code_xpath_select]
-
-[endsect] [/select]
-
-[section:query Using query objects]
-
-[#xpath_query]
-When you call `select_nodes` with an expression string as an argument, a query object is created behind the scenes. A query object represents a compiled XPath expression. Query objects can be needed in the following circumstances:
-
-* You can precompile expressions to query objects to save compilation time if it becomes an issue;
-* You can use query objects to evaluate XPath expressions which result in booleans, numbers or strings;
-* You can get the type of expression value via query object.
-
-Query objects correspond to `xpath_query` type. They are immutable and non-copyable: they are bound to the expression at creation time and can not be cloned. If you want to put query objects in a container, allocate them on heap via `new` operator and store pointers to `xpath_query` in the container.
-
-[#xpath_query::ctor]
-You can create a query object with the constructor that takes XPath expression as an argument:
-
- explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
-
-[#xpath_query::return_type]
-The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, [link xpath_exception] is thrown if exception handling is not disabled (see [sref manual.xpath.errors] for details). After the query is created, you can query the type of the evaluation result using the following function:
-
- xpath_value_type xpath_query::return_type() const;
-
-[#xpath_query::evaluate_boolean][#xpath_query::evaluate_number][#xpath_query::evaluate_string][#xpath_query::evaluate_node_set][#xpath_query::evaluate_node]
-You can evaluate the query using one of the following functions:
-
- bool xpath_query::evaluate_boolean(const xpath_node& n) const;
- double xpath_query::evaluate_number(const xpath_node& n) const;
- string_t xpath_query::evaluate_string(const xpath_node& n) const;
- xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const;
- xpath_node xpath_query::evaluate_node(const xpath_node& n) const;
-
-All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, `evaluate_boolean`, `evaluate_number` and `evaluate_string` always return a result, but `evaluate_node_set` and `evaluate_node` result in an error if the return type is not node set (see [sref manual.xpath.errors]).
-
-[note Calling `node.select_nodes("query")` is equivalent to calling `xpath_query("query").evaluate_node_set(node)`. Calling `node.select_node("query")` is equivalent to calling `xpath_query("query").evaluate_node(node)`.]
-
-[#xpath_query::evaluate_string_buffer]
-Note that `evaluate_string` function returns the STL string; as such, it's not available in [link PUGIXML_NO_STL] mode and also usually allocates memory. There is another string evaluation function:
-
- size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
-
-This function evaluates the string, and then writes the result to `buffer` (but at most `capacity` characters); then it returns the full size of the result in characters, including the terminating zero. If `capacity` is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:
-
-* First call the function with `buffer = 0` and `capacity = 0`; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters;
-* First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again.
-
-This is an example of using query objects ([@samples/xpath_query.cpp]):
-
-[import samples/xpath_query.cpp]
-[code_xpath_query]
-
-[endsect] [/query]
-
-[section:variables Using variables]
-
-XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries.
-
-Variable references have the form '''<code><phrase role="identifier">$name</phrase></code>'''; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to `xpath_query` constructor or to `select_nodes`/`select_node` functions:
-
- explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
- xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const;
- xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
-
-If you're using query objects, you can change the variable values before `evaluate`/`select` calls to change the query behavior.
-
-[note The variable set pointer is stored in the query object; you have to ensure that the lifetime of the set exceeds that of query object.]
-
-[#xpath_variable_set]
-Variable sets correspond to `xpath_variable_set` type, which is essentially a variable container.
-
-[#xpath_variable_set::add]
-You can add new variables with the following function:
-
- xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type);
-
-The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure.
-
-New variables are assigned the default value which depends on the type: `0` for numbers, `false` for booleans, empty string for strings and empty set for node sets.
-
-[#xpath_variable_set::get]
-You can get the existing variables with the following functions:
-
- xpath_variable* xpath_variable_set::get(const char_t* name);
- const xpath_variable* xpath_variable_set::get(const char_t* name) const;
-
-The functions return the variable handle, or null pointer if the variable with the specified name is not found.
-
-[#xpath_variable_set::set]
-Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return `false`; they also return `false` on allocation failure. Note that these functions do not perform any type conversions.
-
- bool xpath_variable_set::set(const char_t* name, bool value);
- bool xpath_variable_set::set(const char_t* name, double value);
- bool xpath_variable_set::set(const char_t* name, const char_t* value);
- bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value);
-
-The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.
-
-[#xpath_variable]
-If setting variables by name is not efficient enough, or if you have to inspect variable information or get variable values, you can use variable handles. A variable corresponds to the `xpath_variable` type, and a variable handle is simply a pointer to `xpath_variable`.
-
-[#xpath_variable::type][#xpath_variable::name]
-In order to get variable information, you can use one of the following functions:
-
- const char_t* xpath_variable::name() const;
- xpath_value_type xpath_variable::type() const;
-
-Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.
-
-[#xpath_variable::get_boolean][#xpath_variable::get_number][#xpath_variable::get_string][#xpath_variable::get_node_set]
-In order to get variable value, you should use one of the following functions, depending on the variable type:
-
- bool xpath_variable::get_boolean() const;
- double xpath_variable::get_number() const;
- const char_t* xpath_variable::get_string() const;
- const xpath_node_set& xpath_variable::get_node_set() const;
-
-These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (`false` for booleans, `NaN` for numbers, empty string for strings and empty set for node sets).
-
-[#xpath_variable::set]
-In order to set variable value, you should use one of the following functions, depending on the variable type:
-
- bool xpath_variable::set(bool value);
- bool xpath_variable::set(double value);
- bool xpath_variable::set(const char_t* value);
- bool xpath_variable::set(const xpath_node_set& value);
-
-These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return `false`; they also return `false` on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.
-
-This is an example of using variables in XPath queries ([@samples/xpath_variables.cpp]):
-
-[import samples/xpath_variables.cpp]
-[code_xpath_variables]
-
-[endsect] [/variables]
-
-[section:errors Error handling]
-
-There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with [link PUGIXML_NO_EXCEPTIONS] define).
-
-[#xpath_exception]
-[#xpath_exception::result]
-[#xpath_exception::what]
-By default, XPath functions throw `xpath_exception` object in case of errors; additionally, in the event any memory allocation fails, an `std::bad_alloc` exception is thrown. Also `xpath_exception` is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions:
-
- virtual const char* xpath_exception::what() const throw();
- const xpath_parse_result& xpath_exception::result() const;
-
-[#xpath_query::unspecified_bool_type]
-[#xpath_query::result]
-If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: `if (query) { ... }`. Additionally, you can get parsing result via the result() accessor:
-
- const xpath_parse_result& xpath_query::result() const;
-
-Without exceptions, evaluating invalid query results in `false`, empty string, NaN or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.
-
-[#xpath_parse_result]
-The information about parsing result is returned via `xpath_parse_result` object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:
-
- struct xpath_parse_result
- {
- const char* error;
- ptrdiff_t offset;
-
- operator bool() const;
- const char* description() const;
- };
-
-[#xpath_parse_result::error]
-Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string.
-
-[#xpath_parse_result::description]
-`description()` member function can be used to get the error message; it never returns the null pointer, so you can safely use `description()` even if query parsing succeeded. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call [link as_wide] to get the `wchar_t` string.
-
-[#xpath_parse_result::offset]
-In addition to the error message, parsing result has an `offset` member, which contains the offset of last successfully parsed character. This offset is in units of [link char_t pugi::char_t] (bytes for character mode, wide characters for wide character mode).
-
-[#xpath_parse_result::bool]
-Parsing result object can be implicitly converted to `bool` like this: `if (result) { ... } else { ... }`.
-
-This is an example of XPath error handling ([@samples/xpath_error.cpp]):
-
-[import samples/xpath_error.cpp]
-[code_xpath_error]
-
-[endsect] [/errors]
-
-[section:w3c Conformance to W3C specification]
-
-Because of the differences in document object models, performance considerations and implementation complexity, pugixml does not provide a fully conformant XPath 1.0 implementation. This is the current list of incompatibilities:
-
-* Consecutive text nodes sharing the same parent are not merged, i.e. in `<node>text1 <![CDATA[data]]> text2</node>` node should have one text node child, but instead has three.
-* Since the document type declaration is not used for parsing, `id()` function always returns an empty node set.
-* Namespace nodes are not supported (affects namespace:: axis).
-* Name tests are performed on QNames in XML document instead of expanded names; for `<foo xmlns:ns1='uri' xmlns:ns2='uri'><ns1:child/><ns2:child/></foo>`, query `foo/ns1:*` will return only the first child, not both of them. Compliant XPath implementations can return both nodes if the user provides appropriate namespace declarations.
-* String functions consider a character to be either a single `char` value or a single `wchar_t` value, depending on the library configuration; this means that some string functions are not fully Unicode-aware. This affects `substring()`, `string-length()` and `translate()` functions.
-
-[endsect] [/w3c]
-
-[endsect] [/xpath]
-
-[section:changes Changelog]
-
-[h5 27.11.2014 - version 1.5]
-
-Major release, featuring a lot of performance improvements and some new features.
-
-* Specification changes:
- # xml_document::load(const char_t*) was renamed to load_string; the old method is still available and will be deprecated in a future release
- # xml_node::select_single_node was renamed to select_node; the old method is still available and will be deprecated in a future release.
-
-* New features:
- # Added xml_node::append_move and other functions for moving nodes within a document
- # Added xpath_query::evaluate_node for evaluating queries with a single node as a result
-
-* Performance improvements:
- # Optimized XML parsing (10-40% faster with clang/gcc, up to 10% faster with MSVC)
- # Optimized memory consumption when copying nodes in the same document (string contents is now shared)
- # Optimized node copying (10% faster for cross-document copies, 3x faster for inter-document copies; also it now consumes a constant amount of stack space)
- # Optimized node output (60% faster; also it now consumes a constant amount of stack space)
- # Optimized XPath allocation (query evaluation now results in fewer temporary allocations)
- # Optimized XPath sorting (node set sorting is 2-3x faster in some cases)
- # Optimized XPath evaluation (XPathMark suite is 100x faster; some commonly used queries are 3-4x faster)
-
-* Compatibility improvements:
- # Fixed xml_node::offset_debug for corner cases
- # Fixed undefined behavior while calling memcpy in some cases
- # Fixed MSVC 2015 compilation warnings
- # Fixed contrib/foreach.hpp for Boost 1.56.0
-
-* Bug fixes
- # Adjusted comment output to avoid malformed documents if the comment value contains "--"
- # Fix XPath sorting for documents that were constructed using append_buffer
- # Fix load_file for wide-character paths with non-ASCII characters in MinGW with C++11 mode enabled
-
-[h5 27.02.2014 - version 1.4]
-
-Major release, featuring various new features, bug fixes and compatibility improvements.
-
-* Specification changes:
- # Documents without element nodes are now rejected with status_no_document_element error, unless parse_fragment option is used
-
-* New features:
- # Added XML fragment parsing (parse_fragment flag)
- # Added PCDATA whitespace trimming (parse_trim_pcdata flag)
- # Added long long support for xml_attribute and xml_text (as_llong, as_ullong and set_value/set overloads)
- # Added hexadecimal integer parsing support for as_int/as_uint/as_llong/as_ullong
- # Added xml_node::append_buffer to improve performance of assembling documents from fragments
- # xml_named_node_iterator is now bidirectional
- # Reduced XPath stack consumption during compilation and evaluation (useful for embedded systems)
-
-* Compatibility improvements:
- # Improved support for platforms without wchar_t support
- # Fixed several false positives in clang static analysis
- # Fixed several compilation warnings for various GCC versions
-
-* Bug fixes:
- # Fixed undefined pointer arithmetic in XPath implementation
- # Fixed non-seekable iostream support for certain stream types, i.e. boost file_source with pipe input
- # Fixed xpath_query::return_type() for some expressions
- # Fixed dllexport issues with xml_named_node_iterator
- # Fixed find_child_by_attribute assertion for attributes with null name/value
-
-[h5 1.05.2012 - version 1.2]
-
-Major release, featuring header-only mode, various interface enhancements (i.e. PCDATA manipulation and C++11 iteration), many other features and compatibility improvements.
-
-* New features:
- # Added xml_text helper class for working with PCDATA/CDATA contents of an element node
- # Added optional header-only mode (controlled by PUGIXML_HEADER_ONLY define)
- # Added xml_node::children() and xml_node::attributes() for C++11 ranged for loop or BOOST_FOREACH
- # Added support for Latin-1 (ISO-8859-1) encoding conversion during loading and saving
- # Added custom default values for '''xml_attribute::as_*''' (they are returned if the attribute does not exist)
- # Added parse_ws_pcdata_single flag for preserving whitespace-only PCDATA in case it's the only child
- # Added format_save_file_text for xml_document::save_file to open files as text instead of binary (changes newlines on Windows)
- # Added format_no_escapes flag to disable special symbol escaping (complements ~parse_escapes)
- # Added support for loading document from streams that do not support seeking
- # Added '''PUGIXML_MEMORY_*''' constants for tweaking allocation behavior (useful for embedded systems)
- # Added PUGIXML_VERSION preprocessor define
-
-* Compatibility improvements:
- # Parser does not require setjmp support (improves compatibility with some embedded platforms, enables clr:pure compilation)
- # STL forward declarations are no longer used (fixes SunCC/RWSTL compilation, fixes clang compilation in C++11 mode)
- # Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C++/CLI compilation
- # Fixed several compilation warnings for various GCC versions, Intel C++ compiler and Clang
-
-* Bug fixes:
- # Fixed unsafe bool conversion to avoid problems on C++/CLI
- # Iterator dereference operator is const now (fixes Boost filter_iterator support)
- # xml_document::save_file now checks for file I/O errors during saving
-
-[h5 1.11.2010 - version 1.0]
-
-Major release, featuring many XPath enhancements, wide character filename support, miscellaneous performance improvements, bug fixes and more.
-
-* XPath:
- # XPath implementation is moved to pugixml.cpp (which is the only source file now); use PUGIXML_NO_XPATH if you want to disable XPath to reduce code size
- # XPath is now supported without exceptions (PUGIXML_NO_EXCEPTIONS); the error handling mechanism depends on the presence of exception support
- # XPath is now supported without STL (PUGIXML_NO_STL)
- # Introduced variable support
- # Introduced new xpath_query::evaluate_string, which works without STL
- # Introduced new xpath_node_set constructor (from an iterator range)
- # Evaluation function now accept attribute context nodes
- # All internal allocations use custom allocation functions
- # Improved error reporting; now a last parsed offset is returned together with the parsing error
-
-* Bug fixes:
- # Fixed memory leak for loading from streams with stream exceptions turned on
- # Fixed custom deallocation function calling with null pointer in one case
- # Fixed missing attributes for iterator category functions; all functions/classes can now be DLL-exported
- # Worked around Digital Mars compiler bug, which lead to minor read overfetches in several functions
- # load_file now works with 2+ Gb files in MSVC/MinGW
- # XPath: fixed memory leaks for incorrect queries
- # XPath: fixed xpath_node() attribute constructor with empty attribute argument
- # XPath: fixed lang() function for non-ASCII arguments
-
-* Specification changes:
- # CDATA nodes containing ]]> are printed as several nodes; while this changes the internal structure, this is the only way to escape CDATA contents
- # Memory allocation errors during parsing now preserve last parsed offset (to give an idea about parsing progress)
- # If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children)
-
-* Additional functionality:
- # Added xml_parse_result default constructor
- # Added xml_document::load_file and xml_document::save_file with wide character paths
- # Added as_utf8 and as_wide overloads for std::wstring/std::string arguments
- # Added DOCTYPE node type (node_doctype) and a special parse flag, parse_doctype, to add such nodes to the document during parsing
- # Added parse_full parse flag mask, which extends parse_default with all node type parsing flags except parse_ws_pcdata
- # Added xml_node::hash_value() and xml_attribute::hash_value() functions for use in hash-based containers
- # Added internal_object() and additional constructor for both xml_node and xml_attribute for easier marshalling (useful for language bindings)
- # Added xml_document::document_element() function
- # Added xml_node::prepend_attribute, xml_node::prepend_child and xml_node::prepend_copy functions
- # Added xml_node::append_child, xml_node::prepend_child, xml_node::insert_child_before and xml_node::insert_child_after overloads for element nodes (with name instead of type)
- # Added xml_document::reset() function
-
-* Performance improvements:
- # xml_node::root() and xml_node::offset_debug() are now O(1) instead of O(logN)
- # Minor parsing optimizations
- # Minor memory optimization for strings in DOM tree (set_name/set_value)
- # Memory optimization for string memory reclaiming in DOM tree (set_name/set_value now reallocate the buffer if memory waste is too big)
- # XPath: optimized document order sorting
- # XPath: optimized child/attribute axis step
- # XPath: optimized number-to-string conversions in MSVC
- # XPath: optimized concat for many arguments
- # XPath: optimized evaluation allocation mechanism: constant and document strings are not heap-allocated
- # XPath: optimized evaluation allocation mechanism: all temporaries' allocations use fast stack-like allocator
-
-* Compatibility:
- # Removed wildcard functions (xml_node::child_w, xml_node::attribute_w, etc.)
- # Removed xml_node::all_elements_by_name
- # Removed xpath_type_t enumeration; use xpath_value_type instead
- # Removed format_write_bom_utf8 enumeration; use format_write_bom instead
- # Removed xml_document::precompute_document_order, xml_attribute::document_order and xml_node::document_order functions; document order sort optimization is now automatic
- # Removed xml_document::parse functions and transfer_ownership struct; use xml_document::load_buffer_inplace and xml_document::load_buffer_inplace_own instead
- # Removed as_utf16 function; use as_wide instead
-
-[h5 1.07.2010 - version 0.9]
-
-Major release, featuring extended and improved Unicode support, miscellaneous performance improvements, bug fixes and more.
-
-* Major Unicode improvements:
- # Introduced encoding support (automatic/manual encoding detection on load, manual encoding selection on save, conversion from/to UTF8, UTF16 LE/BE, UTF32 LE/BE)
- # Introduced wchar_t mode (you can set PUGIXML_WCHAR_MODE define to switch pugixml internal encoding from UTF8 to wchar_t; all functions are switched to their Unicode variants)
- # Load/save functions now support wide streams
-
-* Bug fixes:
- # Fixed document corruption on failed parsing bug
- # XPath string <-> number conversion improvements (increased precision, fixed crash for huge numbers)
- # Improved DOCTYPE parsing: now parser recognizes all well-formed DOCTYPE declarations
- # Fixed xml_attribute::as_uint() for large numbers (i.e. 2^32-1)
- # Fixed xml_node::first_element_by_path for path components that are prefixes of node names, but are not exactly equal to them.
-
-* Specification changes:
- # parse() API changed to load_buffer/load_buffer_inplace/load_buffer_inplace_own; load_buffer APIs do not require zero-terminated strings.
- # Renamed as_utf16 to as_wide
- # Changed xml_node::offset_debug return type and xml_parse_result::offset type to ptrdiff_t
- # Nodes/attributes with empty names are now printed as :anonymous
-
-* Performance improvements:
- # Optimized document parsing and saving
- # Changed internal memory management: internal allocator is used for both metadata and name/value data; allocated pages are deleted if all allocations from them are deleted
- # Optimized memory consumption: sizeof(xml_node_struct) reduced from 40 bytes to 32 bytes on x86
- # Optimized debug mode parsing/saving by order of magnitude
-
-* Miscellaneous:
- # All STL includes except <exception> in pugixml.hpp are replaced with forward declarations
- # xml_node::remove_child and xml_node::remove_attribute now return the operation result
-
-* Compatibility:
- # parse() and as_utf16 are left for compatibility (these functions are deprecated and will be removed in version 1.0)
- # Wildcard functions, document_order/precompute_document_order functions, all_elements_by_name function and format_write_bom_utf8 flag are deprecated and will be removed in version 1.0
- # xpath_type_t enumeration was renamed to xpath_value_type; xpath_type_t is deprecated and will be removed in version 1.0
-
-[h5 8.11.2009 - version 0.5]
-
-Major bugfix release. Changes:
-
-* XPath bugfixes:
- # Fixed translate(), lang() and concat() functions (infinite loops/crashes)
- # Fixed compilation of queries with empty literal strings ("")
- # Fixed axis tests: they never add empty nodes/attributes to the resulting node set now
- # Fixed string-value evaluation for node-set (the result excluded some text descendants)
- # Fixed self:: axis (it behaved like ancestor-or-self::)
- # Fixed following:: and preceding:: axes (they included descendent and ancestor nodes, respectively)
- # Minor fix for namespace-uri() function (namespace declaration scope includes the parent element of namespace declaration attribute)
- # Some incorrect queries are no longer parsed now (i.e. foo: *)
- # Fixed text()/etc. node test parsing bug (i.e. foo[text()] failed to compile)
- # Fixed root step (/) - it now selects empty node set if query is evaluated on empty node
- # Fixed string to number conversion ("123 " converted to NaN, "123 .456" converted to 123.456 - now the results are 123 and NaN, respectively)
- # Node set copying now preserves sorted type; leads to better performance on some queries
-
-* Miscellaneous bugfixes:
- # Fixed xml_node::offset_debug for PI nodes
- # Added empty attribute checks to xml_node::remove_attribute
- # Fixed node_pi and node_declaration copying
- # Const-correctness fixes
-
-* Specification changes:
- # xpath_node::select_nodes() and related functions now throw exception if expression return type is not node set (instead of assertion)
- # xml_node::traverse() now sets depth to -1 for both begin() and end() callbacks (was 0 at begin() and -1 at end())
- # In case of non-raw node printing a newline is output after PCDATA inside nodes if the PCDATA has siblings
- # UTF8 -> wchar_t conversion now considers 5-byte UTF8-like sequences as invalid
-
-* New features:
- # Added xpath_node_set::operator[] for index-based iteration
- # Added xpath_query::return_type()
- # Added getter accessors for memory-management functions
-
-[h5 17.09.2009 - version 0.42]
-
-Maintenance release. Changes:
-
-* Bug fixes:
- # Fixed deallocation in case of custom allocation functions or if delete[] / free are incompatible
- # XPath parser fixed for incorrect queries (i.e. incorrect XPath queries should now always fail to compile)
- # Const-correctness fixes for find_child_by_attribute
- # Improved compatibility (miscellaneous warning fixes, fixed cstring include dependency for GCC)
- # Fixed iterator begin/end and print function to work correctly for empty nodes
-
-* New features:
- # Added PUGIXML_API/PUGIXML_CLASS/PUGIXML_FUNCTION configuration macros to control class/function attributes
- # Added xml_attribute::set_value overloads for different types
-
-[h5 8.02.2009 - version 0.41]
-
-Maintenance release. Changes:
-
-* Bug fixes:
- # Fixed bug with node printing (occasionally some content was not written to output stream)
-
-[h5 18.01.2009 - version 0.4]
-
-Changes:
-
-* Bug fixes:
- # Documentation fix in samples for parse() with manual lifetime control
- # Fixed document order sorting in XPath (it caused wrong order of nodes after xpath_node_set::sort and wrong results of some XPath queries)
-
-* Node printing changes:
- # Single quotes are no longer escaped when printing nodes
- # Symbols in second half of ASCII table are no longer escaped when printing nodes; because of this, format_utf8 flag is deleted as it's no longer needed and format_write_bom is renamed to format_write_bom_utf8.
- # Reworked node printing - now it works via xml_writer interface; implementations for FILE* and std::ostream are available. As a side-effect, xml_document::save_file now works without STL.
-
-* New features:
- # Added unsigned integer support for attributes (xml_attribute::as_uint, xml_attribute::operator=)
- # Now document declaration (<?xml ...?>) is parsed as node with type node_declaration when parse_declaration flag is specified (access to encoding/version is performed as if they were attributes, i.e. doc.child("xml").attribute("version").as_float()); corresponding flags for node printing were also added
- # Added support for custom memory management (see set_memory_management_functions for details)
- # Implemented node/attribute copying (see xml_node::insert\_copy_* and xml_node::append_copy for details)
- # Added find_child_by_attribute and find_child_by_attribute_w to simplify parsing code in some cases (i.e. COLLADA files)
- # Added file offset information querying for debugging purposes (now you're able to determine exact location of any xml_node in parsed file, see xml_node::offset_debug for details)
- # Improved error handling for parsing - now load(), load_file() and parse() return xml_parse_result, which contains error code and last parsed offset; this does not break old interface as xml_parse_result can be implicitly casted to bool.
-
-[h5 31.10.2007 - version 0.34]
-
-Maintenance release. Changes:
-
-* Bug fixes:
- # Fixed bug with loading from text-mode iostreams
- # Fixed leak when transfer_ownership is true and parsing is failing
- # Fixed bug in saving (\\r and \\n are now escaped in attribute values)
- # Renamed free() to destroy() - some macro conflicts were reported
-
-* New features:
- # Improved compatibility (supported Digital Mars C++, MSVC 6, CodeWarrior 8, PGI C++, Comeau, supported PS3 and XBox360)
- # PUGIXML_NO_EXCEPTION flag for platforms without exception handling
-
-[h5 21.02.2007 - version 0.3]
-
-Refactored, reworked and improved version. Changes:
-
-* Interface:
- # Added XPath
- # Added tree modification functions
- # Added no STL compilation mode
- # Added saving document to file
- # Refactored parsing flags
- # Removed xml_parser class in favor of xml_document
- # Added transfer ownership parsing mode
- # Modified the way xml_tree_walker works
- # Iterators are now non-constant
-
-* Implementation:
- # Support of several compilers and platforms
- # Refactored and sped up parsing core
- # Improved standard compliancy
- # Added XPath implementation
- # Fixed several bugs
-
-[h5 6.11.2006 - version 0.2]
-
-First public release. Changes:
-
-* Bug fixes:
- # Fixed child_value() (for empty nodes)
- # Fixed xml_parser_impl warning at W4
-
-* New features:
- # Introduced child_value(name) and child_value_w(name)
- # parse_eol_pcdata and parse_eol_attribute flags + parse_minimal optimizations
- # Optimizations of strconv_t
-
-[h5 15.07.2006 - version 0.1]
-
-First private release for testing purposes
-
-[endsect] [/changes]
-
-[section:apiref API Reference]
-
-This is the reference for all macros, types, enumerations, classes and functions in pugixml. Each symbol is a link that leads to the relevant section of the manual.
-
-Macros:
-
-* `#define `[link PUGIXML_WCHAR_MODE]
-* `#define `[link PUGIXML_NO_XPATH]
-* `#define `[link PUGIXML_NO_STL]
-* `#define `[link PUGIXML_NO_EXCEPTIONS]
-* `#define `[link PUGIXML_API]
-* `#define `[link PUGIXML_CLASS]
-* `#define `[link PUGIXML_FUNCTION]
-* `#define `[link PUGIXML_MEMORY_PAGE_SIZE]
-* `#define `[link PUGIXML_MEMORY_OUTPUT_STACK]
-* `#define `[link PUGIXML_MEMORY_XPATH_PAGE_SIZE]
-* `#define `[link PUGIXML_HEADER_ONLY]
-* `#define `[link PUGIXML_HAS_LONG_LONG]
-
-Types:
-
-* `typedef `/configuration-defined type/` `[link char_t]`;`
-* `typedef `/configuration-defined type/` `[link string_t]`;`
-* `typedef void* (*`[link allocation_function]`)(size_t size);`
-* `typedef void (*`[link deallocation_function]`)(void* ptr);`
-
-Enumerations:
-
-* `enum `[link xml_node_type]
- * [link node_null]
- * [link node_document]
- * [link node_element]
- * [link node_pcdata]
- * [link node_cdata]
- * [link node_comment]
- * [link node_pi]
- * [link node_declaration]
- * [link node_doctype]
- [lbr]
-
-* `enum `[link xml_parse_status]
- * [link status_ok]
- * [link status_file_not_found]
- * [link status_io_error]
- * [link status_out_of_memory]
- * [link status_internal_error]
- * [link status_unrecognized_tag]
- * [link status_bad_pi]
- * [link status_bad_comment]
- * [link status_bad_cdata]
- * [link status_bad_doctype]
- * [link status_bad_pcdata]
- * [link status_bad_start_element]
- * [link status_bad_attribute]
- * [link status_bad_end_element]
- * [link status_end_element_mismatch]
- * [link status_append_invalid_root]
- * [link status_no_document_element]
- [lbr]
-
-* `enum `[link xml_encoding]
- * [link encoding_auto]
- * [link encoding_utf8]
- * [link encoding_utf16_le]
- * [link encoding_utf16_be]
- * [link encoding_utf16]
- * [link encoding_utf32_le]
- * [link encoding_utf32_be]
- * [link encoding_utf32]
- * [link encoding_wchar]
- * [link encoding_latin1]
- [lbr]
-
-* `enum `[link xpath_value_type]
- * [link xpath_type_none]
- * [link xpath_type_node_set]
- * [link xpath_type_number]
- * [link xpath_type_string]
- * [link xpath_type_boolean]
-
-Constants:
-
-* Formatting options bit flags:
- * [link format_default]
- * [link format_indent]
- * [link format_no_declaration]
- * [link format_no_escapes]
- * [link format_raw]
- * [link format_save_file_text]
- * [link format_write_bom]
- [lbr]
-
-* Parsing options bit flags:
- * [link parse_cdata]
- * [link parse_comments]
- * [link parse_declaration]
- * [link parse_default]
- * [link parse_doctype]
- * [link parse_eol]
- * [link parse_escapes]
- * [link parse_fragment]
- * [link parse_full]
- * [link parse_minimal]
- * [link parse_pi]
- * [link parse_trim_pcdata]
- * [link parse_ws_pcdata]
- * [link parse_ws_pcdata_single]
- * [link parse_wconv_attribute]
- * [link parse_wnorm_attribute]
-
-Classes:
-
-* `class `[link xml_attribute]
- * [link xml_attribute::ctor xml_attribute]`();`
- [lbr]
-
- * `bool `[link xml_attribute::empty empty]`() const;`
- * `operator `[link xml_attribute::unspecified_bool_type unspecified_bool_type]`() const;`
- [lbr]
-
- * `bool `[link xml_attribute::comparison operator==]`(const xml_attribute& r) const;`
- * `bool `[link xml_attribute::comparison operator!=]`(const xml_attribute& r) const;`
- * `bool `[link xml_attribute::comparison operator<]`(const xml_attribute& r) const;`
- * `bool `[link xml_attribute::comparison operator>]`(const xml_attribute& r) const;`
- * `bool `[link xml_attribute::comparison operator<=]`(const xml_attribute& r) const;`
- * `bool `[link xml_attribute::comparison operator>=]`(const xml_attribute& r) const;`
- [lbr]
-
- * `size_t `[link xml_attribute::hash_value hash_value]`() const;`
- [lbr]
-
- * `xml_attribute `[link xml_attribute::next_attribute next_attribute]`() const;`
- * `xml_attribute `[link xml_attribute::previous_attribute previous_attribute]`() const;`
- [lbr]
-
- * `const char_t* `[link xml_attribute::name name]`() const;`
- * `const char_t* `[link xml_attribute::value value]`() const;`
- [lbr]
-
- * `const char_t* `[link xml_attribute::as_string as_string]`(const char_t* def = "") const;`
- * `int `[link xml_attribute::as_int as_int]`(int def = 0) const;`
- * `unsigned int `[link xml_attribute::as_uint as_uint]`(unsigned int def = 0) const;`
- * `double `[link xml_attribute::as_double as_double]`(double def = 0) const;`
- * `float `[link xml_attribute::as_float as_float]`(float def = 0) const;`
- * `bool `[link xml_attribute::as_bool as_bool]`(bool def = false) const;`
- * `long long `[link xml_attribute::as_llong as_llong]`(long long def = 0) const;`
- * `unsigned long long `[link xml_attribute::as_ullong as_ullong]`(unsigned long long def = 0) const;`
- [lbr]
-
- * `bool `[link xml_attribute::set_name set_name]`(const char_t* rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(const char_t* rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(int rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(unsigned int rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(double rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(float rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(bool rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(long long rhs);`
- * `bool `[link xml_attribute::set_value set_value]`(unsigned long long rhs);`
- [lbr]
-
- * `xml_attribute& `[link xml_attribute::assign operator=]`(const char_t* rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(int rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(unsigned int rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(double rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(float rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(bool rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(long long rhs);`
- * `xml_attribute& `[link xml_attribute::assign operator=]`(unsnigned long long rhs);`
- [lbr]
-
-* `class `[link xml_node]
- * [link xml_node::ctor xml_node]`();`
- [lbr]
-
- * `bool `[link xml_node::empty empty]`() const;`
- * `operator `[link xml_node::unspecified_bool_type unspecified_bool_type]`() const;`
- [lbr]
-
- * `bool `[link xml_node::comparison operator==]`(const xml_node& r) const;`
- * `bool `[link xml_node::comparison operator!=]`(const xml_node& r) const;`
- * `bool `[link xml_node::comparison operator<]`(const xml_node& r) const;`
- * `bool `[link xml_node::comparison operator>]`(const xml_node& r) const;`
- * `bool `[link xml_node::comparison operator<=]`(const xml_node& r) const;`
- * `bool `[link xml_node::comparison operator>=]`(const xml_node& r) const;`
- [lbr]
-
- * `size_t `[link xml_node::hash_value hash_value]`() const;`
- [lbr]
-
- * `xml_node_type `[link xml_node::type type]`() const;`
- [lbr]
-
- * `const char_t* `[link xml_node::name name]`() const;`
- * `const char_t* `[link xml_node::value value]`() const;`
- [lbr]
-
- * `xml_node `[link xml_node::parent parent]`() const;`
- * `xml_node `[link xml_node::first_child first_child]`() const;`
- * `xml_node `[link xml_node::last_child last_child]`() const;`
- * `xml_node `[link xml_node::next_sibling next_sibling]`() const;`
- * `xml_node `[link xml_node::previous_sibling previous_sibling]`() const;`
- [lbr]
-
- * `xml_attribute `[link xml_node::first_attribute first_attribute]`() const;`
- * `xml_attribute `[link xml_node::last_attribute last_attribute]`() const;`
- [lbr]
-
- * /implementation-defined type/ [link xml_node::children children]`() const;`
- * /implementation-defined type/ [link xml_node::children children]`(const char_t* name) const;`
- * /implementation-defined type/ [link xml_node::attributes attributes]`() const;`
- [lbr]
-
- * `xml_node `[link xml_node::child child]`(const char_t* name) const;`
- * `xml_attribute `[link xml_node::attribute attribute]`(const char_t* name) const;`
- * `xml_node `[link xml_node::next_sibling_name next_sibling]`(const char_t* name) const;`
- * `xml_node `[link xml_node::previous_sibling_name previous_sibling]`(const char_t* name) const;`
- * `xml_node `[link xml_node::find_child_by_attribute find_child_by_attribute]`(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;`
- * `xml_node `[link xml_node::find_child_by_attribute find_child_by_attribute]`(const char_t* attr_name, const char_t* attr_value) const;`
- [lbr]
-
- * `const char_t* `[link xml_node::child_value child_value]`() const;`
- * `const char_t* `[link xml_node::child_value child_value]`(const char_t* name) const;`
- * `xml_text `[link xml_node::text text]`() const;`
- [lbr]
-
- * `typedef xml_node_iterator `[link xml_node_iterator iterator]`;`
- * `iterator `[link xml_node::begin begin]`() const;`
- * `iterator `[link xml_node::end end]`() const;`
- [lbr]
-
- * `typedef xml_attribute_iterator `[link xml_attribute_iterator attribute_iterator]`;`
- * `attribute_iterator `[link xml_node::attributes_begin attributes_begin]`() const;`
- * `attribute_iterator `[link xml_node::attributes_end attributes_end]`() const;`
- [lbr]
-
- * `bool `[link xml_node::traverse traverse]`(xml_tree_walker& walker);`
- [lbr]
-
- * `template <typename Predicate> xml_attribute `[link xml_node::find_attribute find_attribute]`(Predicate pred) const;`
- * `template <typename Predicate> xml_node `[link xml_node::find_child find_child]`(Predicate pred) const;`
- * `template <typename Predicate> xml_node `[link xml_node::find_node find_node]`(Predicate pred) const;`
- [lbr]
-
- * `string_t `[link xml_node::path path]`(char_t delimiter = '/') const;`
- * `xml_node `[link xml_node::first_element_by_path]`(const char_t* path, char_t delimiter = '/') const;`
- * `xml_node `[link xml_node::root root]`() const;`
- * `ptrdiff_t `[link xml_node::offset_debug offset_debug]`() const;`
- [lbr]
-
- * `bool `[link xml_node::set_name set_name]`(const char_t* rhs);`
- * `bool `[link xml_node::set_value set_value]`(const char_t* rhs);`
- [lbr]
-
- * `xml_attribute `[link xml_node::append_attribute append_attribute]`(const char_t* name);`
- * `xml_attribute `[link xml_node::prepend_attribute prepend_attribute]`(const char_t* name);`
- * `xml_attribute `[link xml_node::insert_attribute_after insert_attribute_after]`(const char_t* name, const xml_attribute& attr);`
- * `xml_attribute `[link xml_node::insert_attribute_before insert_attribute_before]`(const char_t* name, const xml_attribute& attr);`
- [lbr]
-
- * `xml_node `[link xml_node::append_child append_child]`(xml_node_type type = node_element);`
- * `xml_node `[link xml_node::prepend_child prepend_child]`(xml_node_type type = node_element);`
- * `xml_node `[link xml_node::insert_child_after insert_child_after]`(xml_node_type type, const xml_node& node);`
- * `xml_node `[link xml_node::insert_child_before insert_child_before]`(xml_node_type type, const xml_node& node);`
- [lbr]
-
- * `xml_node `[link xml_node::append_child append_child]`(const char_t* name);`
- * `xml_node `[link xml_node::prepend_child prepend_child]`(const char_t* name);`
- * `xml_node `[link xml_node::insert_child_after insert_child_after]`(const char_t* name, const xml_node& node);`
- * `xml_node `[link xml_node::insert_child_before insert_child_before]`(const char_t* name, const xml_node& node);`
- [lbr]
-
- * `xml_attribute `[link xml_node::append_copy append_copy]`(const xml_attribute& proto);`
- * `xml_attribute `[link xml_node::prepend_copy prepend_copy]`(const xml_attribute& proto);`
- * `xml_attribute `[link xml_node::insert_copy_after insert_copy_after]`(const xml_attribute& proto, const xml_attribute& attr);`
- * `xml_attribute `[link xml_node::insert_copy_before insert_copy_before]`(const xml_attribute& proto, const xml_attribute& attr);`
- [lbr]
-
- * `xml_node `[link xml_node::append_copy append_copy]`(const xml_node& proto);`
- * `xml_node `[link xml_node::prepend_copy prepend_copy]`(const xml_node& proto);`
- * `xml_node `[link xml_node::insert_copy_after insert_copy_after]`(const xml_node& proto, const xml_node& node);`
- * `xml_node `[link xml_node::insert_copy_before insert_copy_before]`(const xml_node& proto, const xml_node& node);`
- [lbr]
-
- * `xml_node `[link xml_node::append_move append_move]`(const xml_node& moved);`
- * `xml_node `[link xml_node::prepend_move prepend_move]`(const xml_node& moved);`
- * `xml_node `[link xml_node::insert_move_after insert_move_after]`(const xml_node& moved, const xml_node& node);`
- * `xml_node `[link xml_node::insert_move_before insert_move_before]`(const xml_node& moved, const xml_node& node);`
- [lbr]
-
- * `bool `[link xml_node::remove_attribute remove_attribute]`(const xml_attribute& a);`
- * `bool `[link xml_node::remove_attribute remove_attribute]`(const char_t* name);`
- * `bool `[link xml_node::remove_child remove_child]`(const xml_node& n);`
- * `bool `[link xml_node::remove_child remove_child]`(const char_t* name);`
- [lbr]
-
- * `xml_parse_result `[link xml_node::append_buffer append_buffer]`(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- [lbr]
-
- * `void `[link xml_node::print print]`(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;`
- * `void `[link xml_node::print_stream print]`(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;`
- * `void `[link xml_node::print_stream print]`(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;`
- [lbr]
-
- * `xpath_node `[link xml_node::select_node select_node]`(const char_t* query, xpath_variable_set* variables = 0) const;`
- * `xpath_node `[link xml_node::select_node_precomp select_node]`(const xpath_query& query) const;`
- * `xpath_node_set `[link xml_node::select_nodes select_nodes]`(const char_t* query, xpath_variable_set* variables = 0) const;`
- * `xpath_node_set `[link xml_node::select_nodes_precomp select_nodes]`(const xpath_query& query) const;`
- [lbr]
-
-* `class `[link xml_document]
- * [link xml_document::ctor xml_document]`();`
- * `~`[link xml_document::dtor xml_document]`();`
- [lbr]
-
- * `void `[link xml_document::reset reset]`();`
- * `void `[link xml_document::reset reset]`(const xml_document& proto);`
- [lbr]
-
- * `xml_parse_result `[link xml_document::load_stream load]`(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- * `xml_parse_result `[link xml_document::load_stream load]`(std::wistream& stream, unsigned int options = parse_default);`
- [lbr]
-
- * `xml_parse_result `[link xml_document::load_string load_string]`(const char_t* contents, unsigned int options = parse_default);`
- [lbr]
-
- * `xml_parse_result `[link xml_document::load_file load_file]`(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- * `xml_parse_result `[link xml_document::load_file_wide load_file]`(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- [lbr]
-
- * `xml_parse_result `[link xml_document::load_buffer load_buffer]`(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- * `xml_parse_result `[link xml_document::load_buffer_inplace load_buffer_inplace]`(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- * `xml_parse_result `[link xml_document::load_buffer_inplace_own load_buffer_inplace_own]`(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
- [lbr]
-
- * `bool `[link xml_document::save_file save_file]`(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
- * `bool `[link xml_document::save_file_wide save_file]`(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
- [lbr]
-
- * `void `[link xml_document::save_stream save]`(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
- * `void `[link xml_document::save_stream save]`(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;`
- [lbr]
-
- * `void `[link xml_document::save save]`(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
- [lbr]
-
- * `xml_node `[link xml_document::document_element document_element]`() const;`
- [lbr]
-
-* `struct `[link xml_parse_result]
- * `xml_parse_status `[link xml_parse_result::status status]`;`
- * `ptrdiff_t `[link xml_parse_result::offset offset]`;`
- * `xml_encoding `[link xml_parse_result::encoding encoding]`;`
- [lbr]
-
- * `operator `[link xml_parse_result::bool bool]`() const;`
- * `const char* `[link xml_parse_result::description description]`() const;`
- [lbr]
-
-* `class `[link xml_node_iterator]
-* `class `[link xml_attribute_iterator]
-[lbr]
-
-* `class `[link xml_tree_walker]
- * `virtual bool `[link xml_tree_walker::begin begin]`(xml_node& node);`
- * `virtual bool `[link xml_tree_walker::for_each for_each]`(xml_node& node) = 0;`
- * `virtual bool `[link xml_tree_walker::end end]`(xml_node& node);`
- [lbr]
-
- * `int `[link xml_tree_walker::depth depth]`() const;`
- [lbr]
-
-* `class `[link xml_text]
- * `bool `[link xml_text::empty empty]`() const;`
- * `operator `[link xml_text::unspecified_bool_type]`() const;`
- [lbr]
-
- * `const char_t* `[link xml_text::get]`() const;`
- [lbr]
-
- * `const char_t* `[link xml_text::as_string as_string]`(const char_t* def = "") const;`
- * `int `[link xml_text::as_int as_int]`(int def = 0) const;`
- * `unsigned int `[link xml_text::as_uint as_uint]`(unsigned int def = 0) const;`
- * `double `[link xml_text::as_double as_double]`(double def = 0) const;`
- * `float `[link xml_text::as_float as_float]`(float def = 0) const;`
- * `bool `[link xml_text::as_bool as_bool]`(bool def = false) const;`
- * `long long `[link xml_text::as_llong as_llong]`(long long def = 0) const;`
- * `unsigned long long `[link xml_text::as_ullong as_ullong]`(unsigned long long def = 0) const;`
- [lbr]
-
- * `bool `[link xml_text::set set]`(const char_t* rhs);`
- [lbr]
-
- * `bool `[link xml_text::set set]`(int rhs);`
- * `bool `[link xml_text::set set]`(unsigned int rhs);`
- * `bool `[link xml_text::set set]`(double rhs);`
- * `bool `[link xml_text::set set]`(float rhs);`
- * `bool `[link xml_text::set set]`(bool rhs);`
- * `bool `[link xml_text::set set]`(long long rhs);`
- * `bool `[link xml_text::set set]`(unsigned long long rhs);`
- [lbr]
-
- * `xml_text& `[link xml_text::assign operator=]`(const char_t* rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(int rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(unsigned int rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(double rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(float rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(bool rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(long long rhs);`
- * `xml_text& `[link xml_text::assign operator=]`(unsigned long long rhs);`
- [lbr]
-
- * `xml_node `[link xml_text::data data]`() const;`
- [lbr]
-
-* `class `[link xml_writer]
- * `virtual void `[link xml_writer::write write]`(const void* data, size_t size) = 0;`
- [lbr]
-
-* `class `[link xml_writer_file]`: public xml_writer`
- * [link xml_writer_file]`(void* file);`
- [lbr]
-
-* `class `[link xml_writer_stream]`: public xml_writer`
- * [link xml_writer_stream]`(std::ostream& stream);`
- * [link xml_writer_stream]`(std::wostream& stream);`
- [lbr]
-
-* `struct `[link xpath_parse_result]
- * `const char* `[link xpath_parse_result::error error]`;`
- * `ptrdiff_t `[link xpath_parse_result::offset offset]`;`
-
- * `operator `[link xpath_parse_result::bool bool]`() const;`
- * `const char* `[link xpath_parse_result::description description]`() const;`
- [lbr]
-
-* `class `[link xpath_query]
- * `explicit `[link xpath_query::ctor xpath_query]`(const char_t* query, xpath_variable_set* variables = 0);`
- [lbr]
-
- * `bool `[link xpath_query::evaluate_boolean evaluate_boolean]`(const xpath_node& n) const;`
- * `double `[link xpath_query::evaluate_number evaluate_number]`(const xpath_node& n) const;`
- * `string_t `[link xpath_query::evaluate_string evaluate_string]`(const xpath_node& n) const;`
- * `size_t `[link xpath_query::evaluate_string_buffer evaluate_string]`(char_t* buffer, size_t capacity, const xpath_node& n) const;`
- * `xpath_node_set `[link xpath_query::evaluate_node_set evaluate_node_set]`(const xpath_node& n) const;`
- * `xpath_node `[link xpath_query::evaluate_node evaluate_node]`(const xpath_node& n) const;`
- [lbr]
-
- * `xpath_value_type `[link xpath_query::return_type return_type]`() const;`
- [lbr]
-
- * `const xpath_parse_result& `[link xpath_query::result result]`() const;`
- * `operator `[link xpath_query::unspecified_bool_type unspecified_bool_type]`() const;`
- [lbr]
-
-* `class `[link xpath_exception]`: public std::exception`
- * `virtual const char* `[link xpath_exception::what what]`() const throw();`
- [lbr]
-
- * `const xpath_parse_result& `[link xpath_exception::result result]`() const;`
- [lbr]
-
-* `class `[link xpath_node]
- * [link xpath_node::ctor xpath_node]`();`
- * [link xpath_node::ctor xpath_node]`(const xml_node& node);`
- * [link xpath_node::ctor xpath_node]`(const xml_attribute& attribute, const xml_node& parent);`
- [lbr]
-
- * `xml_node `[link xpath_node::node node]`() const;`
- * `xml_attribute `[link xpath_node::attribute attribute]`() const;`
- * `xml_node `[link xpath_node::parent parent]`() const;`
- [lbr]
-
- * `operator `[link xpath_node::unspecified_bool_type unspecified_bool_type]`() const;`
- * `bool `[link xpath_node::comparison operator==]`(const xpath_node& n) const;`
- * `bool `[link xpath_node::comparison operator!=]`(const xpath_node& n) const;`
- [lbr]
-
-* `class `[link xpath_node_set]
- * [link xpath_node_set::ctor xpath_node_set]`();`
- * [link xpath_node_set::ctor xpath_node_set]`(const_iterator begin, const_iterator end, type_t type = type_unsorted);`
- [lbr]
-
- * `typedef const xpath_node* `[link xpath_node_set::const_iterator const_iterator]`;`
- * `const_iterator `[link xpath_node_set::begin begin]`() const;`
- * `const_iterator `[link xpath_node_set::end end]`() const;`
- [lbr]
-
- * `const xpath_node& `[link xpath_node_set::index operator\[\]]`(size_t index) const;`
- * `size_t `[link xpath_node_set::size size]`() const;`
- * `bool `[link xpath_node_set::empty empty]`() const;`
- [lbr]
-
- * `xpath_node `[link xpath_node_set::first first]`() const;`
- [lbr]
-
- * `enum type_t {`[link xpath_node_set::type_unsorted type_unsorted], [link xpath_node_set::type_sorted type_sorted], [link xpath_node_set::type_sorted_reverse type_sorted_reverse]`};`
- * `type_t `[link xpath_node_set::type type]`() const;`
- * `void `[link xpath_node_set::sort sort]`(bool reverse = false);`
- [lbr]
-
-* `class `[link xpath_variable]
- * `const char_t* `[link xpath_variable::name name]`() const;`
- * `xpath_value_type `[link xpath_variable::type type]`() const;`
- [lbr]
-
- * `bool `[link xpath_variable::get_boolean get_boolean]`() const;`
- * `double `[link xpath_variable::get_number get_number]`() const;`
- * `const char_t* `[link xpath_variable::get_string get_string]`() const;`
- * `const xpath_node_set& `[link xpath_variable::get_node_set get_node_set]`() const;`
- [lbr]
-
- * `bool `[link xpath_variable::set set]`(bool value);`
- * `bool `[link xpath_variable::set set]`(double value);`
- * `bool `[link xpath_variable::set set]`(const char_t* value);`
- * `bool `[link xpath_variable::set set]`(const xpath_node_set& value);`
- [lbr]
-
-* `class `[link xpath_variable_set]
- * `xpath_variable* `[link xpath_variable_set::add add]`(const char_t* name, xpath_value_type type);`
- [lbr]
-
- * `bool `[link xpath_variable_set::set set]`(const char_t* name, bool value);`
- * `bool `[link xpath_variable_set::set set]`(const char_t* name, double value);`
- * `bool `[link xpath_variable_set::set set]`(const char_t* name, const char_t* value);`
- * `bool `[link xpath_variable_set::set set]`(const char_t* name, const xpath_node_set& value);`
- [lbr]
-
- * `xpath_variable* `[link xpath_variable_set::get get]`(const char_t* name);`
- * `const xpath_variable* `[link xpath_variable_set::get get]`(const char_t* name) const;`
- [lbr]
-
-Functions:
-
-* `std::string `[link as_utf8]`(const wchar_t* str);`
-* `std::string `[link as_utf8]`(const std::wstring& str);`
-* `std::wstring `[link as_wide]`(const char* str);`
-* `std::wstring `[link as_wide]`(const std::string& str);`
-* `void `[link set_memory_management_functions]`(allocation_function allocate, deallocation_function deallocate);`
-* `allocation_function `[link get_memory_allocation_function]`();`
-* `deallocation_function `[link get_memory_deallocation_function]`();`
-
-[endsect] [/apiref]
-
-[section:toc Table of Contents]
-
-toc-placeholder
-
-[endsect] [/toc]
-
-[/ vim:et ]
diff --git a/docs/manual.xsl b/docs/manual.xsl
deleted file mode 100644
index 783dff7..0000000
--- a/docs/manual.xsl
+++ /dev/null
@@ -1,118 +0,0 @@
-<?xml version='1.0'?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:template name="navbar.section">
- <xsl:param name="name" select="/foo" />
- <xsl:param name="targets" select="key('id',$name)"/>
- <xsl:param name="target" select="$targets[1]"/>
- <xsl:param name="text" select="normalize-space($target/title)" />
-
- <xsl:choose>
- <xsl:when test="@id != $name">
- <a>
- <xsl:attribute name="href">
- <xsl:call-template name="href.target">
- <xsl:with-param name="object" select="$target"/>
- </xsl:call-template>
- </xsl:attribute>
- <xsl:value-of select="$text" />
- </a>
- </xsl:when>
- <xsl:otherwise>
- <b>
- <xsl:value-of select="$text" />
- </b>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="navbar.contents">
- <a href="http://pugixml.org/"><xsl:value-of select="/*/title" /></a> manual |
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual'" /><xsl:with-param name="text" select="'Overview'" /></xsl:call-template> |
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.install'" /></xsl:call-template> |
- Document:
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.dom'" /><xsl:with-param name="text" select="'Object model'" /></xsl:call-template>
- <xsl:text disable-output-escaping="yes"> &amp;middot; </xsl:text>
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.loading'" /><xsl:with-param name="text" select="'Loading'" /></xsl:call-template>
- <xsl:text disable-output-escaping="yes"> &amp;middot; </xsl:text>
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.access'" /><xsl:with-param name="text" select="'Accessing'" /></xsl:call-template>
- <xsl:text disable-output-escaping="yes"> &amp;middot; </xsl:text>
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.modify'" /><xsl:with-param name="text" select="'Modifying'" /></xsl:call-template>
- <xsl:text disable-output-escaping="yes"> &amp;middot; </xsl:text>
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.saving'" /><xsl:with-param name="text" select="'Saving'" /></xsl:call-template> |
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.xpath'" /></xsl:call-template> |
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.apiref'" /></xsl:call-template> |
- <xsl:call-template name="navbar.section"><xsl:with-param name="name" select="'manual.toc'" /></xsl:call-template>
- </xsl:template>
-
- <xsl:template name="header.navigation">
- <xsl:param name="prev" select="/foo"/>
- <xsl:param name="next" select="/foo"/>
- <xsl:param name="nav.context"/>
-
- <table width="100%"><tr>
- <td>
- <xsl:call-template name="navbar.contents" />
- </td>
- <td width="*" align="right">
- <xsl:call-template name="navbar.spirit">
- <xsl:with-param name="prev" select="$prev"/>
- <xsl:with-param name="next" select="$next"/>
- <xsl:with-param name="nav.context" select="$nav.context"/>
- </xsl:call-template>
- </td>
-
- </tr></table>
- <hr/>
- </xsl:template>
-
- <xsl:template name="footer.navigation">
- <xsl:param name="prev" select="/foo"/>
- <xsl:param name="next" select="/foo"/>
- <xsl:param name="nav.context"/>
-
- <hr/>
- <table width="100%"><tr>
- <td>
- <xsl:call-template name="navbar.contents" />
- </td>
- <td width="*" align="right">
- <xsl:call-template name="navbar.spirit">
- <xsl:with-param name="prev" select="$prev"/>
- <xsl:with-param name="next" select="$next"/>
- <xsl:with-param name="nav.context" select="$nav.context"/>
- </xsl:call-template>
- </td>
-
- </tr></table>
- </xsl:template>
-
- <xsl:template match="section[@id='manual.toc']/para[normalize-space(text())='toc-placeholder']">
- <xsl:call-template name="make.toc">
- <xsl:with-param name="toc-context" select="." />
- <xsl:with-param name="toc.title.p" select="false()" />
- <xsl:with-param name="nodes" select="/book/section" />
- </xsl:call-template>
- </xsl:template>
-
- <xsl:template name="book.titlepage" />
-
- <xsl:template name="anchor">
- <xsl:param name="node" select="." />
- <xsl:param name="conditional" select="1" />
- <xsl:variable name="id">
- <xsl:call-template name="object.id">
- <xsl:with-param name="object" select="$node"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$node/@id or $node/@xml:id">
- <a name="{$id}"/>
- </xsl:when>
- <xsl:when test="$conditional = 0 and local-name($node) != 'bridgehead'">
- <xsl:message terminate="yes">
- <xsl:text>ERROR: Autogenerated id detected for element </xsl:text><xsl:value-of select="local-name($node)" />
- </xsl:message>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-</xsl:stylesheet>
diff --git a/docs/manual/access.html b/docs/manual/access.html
deleted file mode 100644
index 8942a26..0000000
--- a/docs/manual/access.html
+++ /dev/null
@@ -1,900 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Accessing document data</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="loading.html" title="Loading document">
-<link rel="next" href="modify.html" title="Modifying document data">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <b>Accessing</b> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="loading.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="modify.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.access"></a><a class="link" href="access.html" title="Accessing document data"> Accessing document data</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="access.html#manual.access.basic"> Basic traversal functions</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.nodedata"> Getting node data</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.attrdata"> Getting attribute data</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.contents"> Contents-based traversal functions</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.rangefor"> Range-based for-loop support</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.iterators"> Traversing node/attribute lists
- via iterators</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.walker"> Recursive traversal with xml_tree_walker</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.predicate"> Searching for nodes/attributes
- with predicates</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.text"> Working with text contents</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.misc"> Miscellaneous functions</a></span></dt>
-</dl></div>
-<p>
- pugixml features an extensive interface for getting various types of data from
- the document and for traversing the document. This section provides documentation
- for all such functions that do not modify the tree except for XPath-related
- functions; see <a class="xref" href="xpath.html" title="XPath"> XPath</a> for XPath reference. As discussed in <a class="xref" href="dom.html#manual.dom.cpp" title="C++ interface"> C++ interface</a>,
- there are two types of handles to tree data - <a class="link" href="dom.html#xml_node">xml_node</a>
- and <a class="link" href="dom.html#xml_attribute">xml_attribute</a>. The handles have special
- null (empty) values which propagate through various functions and thus are
- useful for writing more concise code; see <a class="link" href="dom.html#node_null">this description</a>
- for details. The documentation in this section will explicitly state the results
- of all function in case of null inputs.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.basic"></a><a class="link" href="access.html#manual.access.basic" title="Basic traversal functions"> Basic traversal functions</a>
-</h3></div></div></div>
-<a name="xml_node::parent"></a><a name="xml_node::first_child"></a><a name="xml_node::last_child"></a><a name="xml_node::next_sibling"></a><a name="xml_node::previous_sibling"></a><a name="xml_node::first_attribute"></a><a name="xml_node::last_attribute"></a><a name="xml_attribute::next_attribute"></a><a name="xml_attribute::previous_attribute"></a><p>
- The internal representation of the document is a tree, where each node has
- a list of child nodes (the order of children corresponds to their order in
- the XML representation), and additionally element nodes have a list of attributes,
- which is also ordered. Several functions are provided in order to let you
- get from one node in the tree to the other. These functions roughly correspond
- to the internal representation, and thus are usually building blocks for
- other methods of traversing (i.e. XPath traversals are based on these functions).
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">parent</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">first_child</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">last_child</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">next_sibling</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">previous_sibling</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">first_attribute</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">last_attribute</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">next_attribute</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">previous_attribute</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">parent</span></code> function returns the
- node's parent; all non-null nodes except the document have non-null parent.
- <code class="computeroutput"><span class="identifier">first_child</span></code> and <code class="computeroutput"><span class="identifier">last_child</span></code> return the first and last child
- of the node, respectively; note that only document nodes and element nodes
- can have non-empty child node list. If node has no children, both functions
- return null nodes. <code class="computeroutput"><span class="identifier">next_sibling</span></code>
- and <code class="computeroutput"><span class="identifier">previous_sibling</span></code> return
- the node that's immediately to the right/left of this node in the children
- list, respectively - for example, in <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">/&gt;&lt;</span><span class="identifier">b</span><span class="special">/&gt;&lt;</span><span class="identifier">c</span><span class="special">/&gt;</span></code>,
- calling <code class="computeroutput"><span class="identifier">next_sibling</span></code> for
- a handle that points to <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">b</span><span class="special">/&gt;</span></code>
- results in a handle pointing to <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">c</span><span class="special">/&gt;</span></code>,
- and calling <code class="computeroutput"><span class="identifier">previous_sibling</span></code>
- results in handle pointing to <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">/&gt;</span></code>.
- If node does not have next/previous sibling (this happens if it is the last/first
- node in the list, respectively), the functions return null nodes. <code class="computeroutput"><span class="identifier">first_attribute</span></code>, <code class="computeroutput"><span class="identifier">last_attribute</span></code>,
- <code class="computeroutput"><span class="identifier">next_attribute</span></code> and <code class="computeroutput"><span class="identifier">previous_attribute</span></code> functions behave similarly
- to the corresponding child node functions and allow to iterate through attribute
- list in the same way.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Because of memory consumption reasons, attributes do not have a link to
- their parent nodes. Thus there is no <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">parent</span><span class="special">()</span></code> function.
- </p></td></tr>
-</table></div>
-<p>
- Calling any of the functions above on the null handle results in a null handle
- - i.e. <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">next_sibling</span><span class="special">()</span></code>
- returns the second child of <code class="computeroutput"><span class="identifier">node</span></code>,
- and null handle if <code class="computeroutput"><span class="identifier">node</span></code> is
- null, has no children at all or if it has only one child node.
- </p>
-<p>
- With these functions, you can iterate through all child nodes and display
- all attributes like this (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool:"</span><span class="special">;</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">first_attribute</span><span class="special">();</span> <span class="identifier">attr</span><span class="special">;</span> <span class="identifier">attr</span> <span class="special">=</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">next_attribute</span><span class="special">())</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.nodedata"></a><a class="link" href="access.html#manual.access.nodedata" title="Getting node data"> Getting node data</a>
-</h3></div></div></div>
-<a name="xml_node::name"></a><a name="xml_node::value"></a><p>
- Apart from structural information (parent, child nodes, attributes), nodes
- can have name and value, both of which are strings. Depending on node type,
- name or value may be absent. <a class="link" href="dom.html#node_document">node_document</a>
- nodes do not have a name or value, <a class="link" href="dom.html#node_element">node_element</a>
- and <a class="link" href="dom.html#node_declaration">node_declaration</a> nodes always
- have a name but never have a value, <a class="link" href="dom.html#node_pcdata">node_pcdata</a>,
- <a class="link" href="dom.html#node_cdata">node_cdata</a>, <a class="link" href="dom.html#node_comment">node_comment</a>
- and <a class="link" href="dom.html#node_doctype">node_doctype</a> nodes never have a name
- but always have a value (it may be empty though), <a class="link" href="dom.html#node_pi">node_pi</a>
- nodes always have a name and a value (again, value may be empty). In order
- to get node's name or value, you can use the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- In case node does not have a name or value or if the node handle is null,
- both functions return empty strings - they never return null pointers.
- </p>
-<a name="xml_node::child_value"></a><p>
- It is common to store data as text contents of some node - i.e. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;&lt;</span><span class="identifier">description</span><span class="special">&gt;</span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special">&lt;/</span><span class="identifier">description</span><span class="special">&gt;&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>.
- In this case, <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">description</span><span class="special">&gt;</span></code> node does not have a value, but instead
- has a child of type <a class="link" href="dom.html#node_pcdata">node_pcdata</a> with value
- <code class="computeroutput"><span class="string">"This is a node"</span></code>. pugixml
- provides several helper functions to parse such data:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">child_value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">child_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_text</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">text</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">child_value</span><span class="special">()</span></code>
- returns the value of the first child with type <a class="link" href="dom.html#node_pcdata">node_pcdata</a>
- or <a class="link" href="dom.html#node_cdata">node_cdata</a>; <code class="computeroutput"><span class="identifier">child_value</span><span class="special">(</span><span class="identifier">name</span><span class="special">)</span></code>
- is a simple wrapper for <code class="computeroutput"><span class="identifier">child</span><span class="special">(</span><span class="identifier">name</span><span class="special">).</span><span class="identifier">child_value</span><span class="special">()</span></code>.
- For the above example, calling <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"description"</span><span class="special">)</span></code> and <code class="computeroutput"><span class="identifier">description</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">()</span></code> will both produce string <code class="computeroutput"><span class="string">"This is a node"</span></code>. If there is no
- child with relevant type, or if the handle is null, <code class="computeroutput"><span class="identifier">child_value</span></code>
- functions return empty string.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">text</span><span class="special">()</span></code>
- returns a special object that can be used for working with PCDATA contents
- in more complex cases than just retrieving the value; it is described in
- <a class="xref" href="access.html#manual.access.text" title="Working with text contents"> Working with text contents</a> sections.
- </p>
-<p>
- There is an example of using some of these functions <a class="link" href="access.html#code_traverse_base_data">at
- the end of the next section</a>.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.attrdata"></a><a class="link" href="access.html#manual.access.attrdata" title="Getting attribute data"> Getting attribute data</a>
-</h3></div></div></div>
-<a name="xml_attribute::name"></a><a name="xml_attribute::value"></a><p>
- All attributes have name and value, both of which are strings (value may
- be empty). There are two corresponding accessors, like for <code class="computeroutput"><span class="identifier">xml_node</span></code>:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- In case the attribute handle is null, both functions return empty strings
- - they never return null pointers.
- </p>
-<a name="xml_attribute::as_string"></a><p>
- If you need a non-empty string if the attribute handle is null (for example,
- you need to get the option value from XML attribute, but if it is not specified,
- you need it to default to <code class="computeroutput"><span class="string">"sorted"</span></code>
- instead of <code class="computeroutput"><span class="string">""</span></code>), you
- can use <code class="computeroutput"><span class="identifier">as_string</span></code> accessor:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_string</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">def</span> <span class="special">=</span> <span class="string">""</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- It returns <code class="computeroutput"><span class="identifier">def</span></code> argument if
- the attribute handle is null. If you do not specify the argument, the function
- is equivalent to <code class="computeroutput"><span class="identifier">value</span><span class="special">()</span></code>.
- </p>
-<a name="xml_attribute::as_int"></a><a name="xml_attribute::as_uint"></a><a name="xml_attribute::as_double"></a><a name="xml_attribute::as_float"></a><a name="xml_attribute::as_bool"></a><a name="xml_attribute::as_llong"></a><a name="xml_attribute::as_ullong"></a><p>
- In many cases attribute values have types that are not strings - i.e. an
- attribute may always contain values that should be treated as integers, despite
- the fact that they are represented as strings in XML. pugixml provides several
- accessors that convert attribute value to some other type:
- </p>
-<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_int</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_uint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">double</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_double</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">float</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_float</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_bool</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_llong</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">as_ullong</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">as_int</span></code>, <code class="computeroutput"><span class="identifier">as_uint</span></code>,
- <code class="computeroutput"><span class="identifier">as_llong</span></code>, <code class="computeroutput"><span class="identifier">as_ullong</span></code>,
- <code class="computeroutput"><span class="identifier">as_double</span></code> and <code class="computeroutput"><span class="identifier">as_float</span></code> convert attribute values to numbers.
- If attribute handle is null or attribute value is empty, <code class="computeroutput"><span class="identifier">def</span></code>
- argument is returned (which is 0 by default). Otherwise, all leading whitespace
- characters are truncated, and the remaining string is parsed as an integer
- number in either decimal or hexadecimal form (applicable to <code class="computeroutput"><span class="identifier">as_int</span></code>, <code class="computeroutput"><span class="identifier">as_uint</span></code>,
- <code class="computeroutput"><span class="identifier">as_llong</span></code> and <code class="computeroutput"><span class="identifier">as_ullong</span></code>; hexadecimal format is used if
- the number has <code class="computeroutput"><span class="number">0</span><span class="identifier">x</span></code>
- or <code class="computeroutput"><span class="number">0</span><span class="identifier">X</span></code>
- prefix) or as a floating point number in either decimal or scientific form
- (<code class="computeroutput"><span class="identifier">as_double</span></code> or <code class="computeroutput"><span class="identifier">as_float</span></code>). Any extra characters are silently
- discarded, i.e. <code class="computeroutput"><span class="identifier">as_int</span></code> will
- return <code class="computeroutput"><span class="number">1</span></code> for string <code class="computeroutput"><span class="string">"1abc"</span></code>.
- </p>
-<p>
- In case the input string contains a number that is out of the target numeric
- range, the result is undefined.
- </p>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Number conversion functions depend on current C locale as set with <code class="computeroutput"><span class="identifier">setlocale</span></code>, so may return unexpected results
- if the locale is different from <code class="computeroutput"><span class="string">"C"</span></code>.
- </p></td></tr>
-</table></div>
-<p>
- <code class="computeroutput"><span class="identifier">as_bool</span></code> converts attribute
- value to boolean as follows: if attribute handle is null, <code class="computeroutput"><span class="identifier">def</span></code>
- argument is returned (which is <code class="computeroutput"><span class="keyword">false</span></code>
- by default). If attribute value is empty, <code class="computeroutput"><span class="keyword">false</span></code>
- is returned. Otherwise, <code class="computeroutput"><span class="keyword">true</span></code>
- is returned if the first character is one of <code class="computeroutput"><span class="char">'1'</span><span class="special">,</span> <span class="char">'t'</span><span class="special">,</span>
- <span class="char">'T'</span><span class="special">,</span> <span class="char">'y'</span><span class="special">,</span> <span class="char">'Y'</span></code>.
- This means that strings like <code class="computeroutput"><span class="string">"true"</span></code>
- and <code class="computeroutput"><span class="string">"yes"</span></code> are recognized
- as <code class="computeroutput"><span class="keyword">true</span></code>, while strings like
- <code class="computeroutput"><span class="string">"false"</span></code> and <code class="computeroutput"><span class="string">"no"</span></code> are recognized as <code class="computeroutput"><span class="keyword">false</span></code>. For more complex matching you'll have
- to write your own function.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- <code class="computeroutput"><span class="identifier">as_llong</span></code> and <code class="computeroutput"><span class="identifier">as_ullong</span></code> are only available if your
- platform has reliable support for the <code class="computeroutput"><span class="keyword">long</span>
- <span class="keyword">long</span></code> type, including string conversions.
- </p></td></tr>
-</table></div>
-<a name="code_traverse_base_data"></a><p>
- This is an example of using these functions, along with node data retrieval
- ones (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">": AllowRemote "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"AllowRemote"</span><span class="special">).</span><span class="identifier">as_bool</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", Timeout "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Timeout"</span><span class="special">).</span><span class="identifier">as_int</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", Description '"</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"Description"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"'\n"</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.contents"></a><a class="link" href="access.html#manual.access.contents" title="Contents-based traversal functions"> Contents-based traversal functions</a>
-</h3></div></div></div>
-<a name="xml_node::child"></a><a name="xml_node::attribute"></a><a name="xml_node::next_sibling_name"></a><a name="xml_node::previous_sibling_name"></a><p>
- Since a lot of document traversal consists of finding the node/attribute
- with the correct name, there are special functions for that purpose:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">child</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">previous_sibling</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">child</span></code> and <code class="computeroutput"><span class="identifier">attribute</span></code>
- return the first child/attribute with the specified name; <code class="computeroutput"><span class="identifier">next_sibling</span></code>
- and <code class="computeroutput"><span class="identifier">previous_sibling</span></code> return
- the first sibling in the corresponding direction with the specified name.
- All string comparisons are case-sensitive. In case the node handle is null
- or there is no node/attribute with the specified name, null handle is returned.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">child</span></code> and <code class="computeroutput"><span class="identifier">next_sibling</span></code>
- functions can be used together to loop through all child nodes with the desired
- name like this:
- </p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-</pre>
-<a name="xml_node::find_child_by_attribute"></a><p>
- Occasionally the needed node is specified not by the unique name but instead
- by the value of some attribute; for example, it is common to have node collections
- with each node having a unique id: <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">group</span><span class="special">&gt;&lt;</span><span class="identifier">item</span> <span class="identifier">id</span><span class="special">=</span><span class="string">"1"</span><span class="special">/&gt;</span> <span class="special">&lt;</span><span class="identifier">item</span> <span class="identifier">id</span><span class="special">=</span><span class="string">"2"</span><span class="special">/&gt;&lt;/</span><span class="identifier">group</span><span class="special">&gt;</span></code>. There are two functions for finding
- child nodes based on the attribute values:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- The three-argument function returns the first child node with the specified
- name which has an attribute with the specified name/value; the two-argument
- function skips the name test for the node, which can be useful for searching
- in heterogeneous collections. If the node handle is null or if no node is
- found, null handle is returned. All string comparisons are case-sensitive.
- </p>
-<p>
- In all of the above functions, all arguments have to be valid strings; passing
- null pointers results in undefined behavior.
- </p>
-<p>
- This is an example of using these functions (<a href="../samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool for *.dae generation: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">,</span> <span class="string">"OutputFileMasks"</span><span class="special">,</span> <span class="string">"*.dae"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-
-<span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.rangefor"></a><a class="link" href="access.html#manual.access.rangefor" title="Range-based for-loop support"> Range-based for-loop support</a>
-</h3></div></div></div>
-<a name="xml_node::children"></a><a name="xml_node::attributes"></a><p>
- If your C++ compiler supports range-based for-loop (this is a C++11 feature,
- at the time of writing it's supported by Microsoft Visual Studio 11 Beta,
- GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional
- helpers are provided to support this; note that they are also compatible
- with <a href="http://www.boost.org/libs/foreach/" target="_top">Boost Foreach</a>,
- and possibly other pre-C++11 foreach facilities.
- </p>
-<pre class="programlisting"><span class="emphasis"><em>implementation-defined type</em></span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">children</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="emphasis"><em>implementation-defined type</em></span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">children</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="emphasis"><em>implementation-defined type</em></span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">attributes</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">children</span></code> function allows
- you to enumerate all child nodes; <code class="computeroutput"><span class="identifier">children</span></code>
- function with <code class="computeroutput"><span class="identifier">name</span></code> argument
- allows you to enumerate all child nodes with a specific name; <code class="computeroutput"><span class="identifier">attributes</span></code> function allows you to enumerate
- all attributes of the node. Note that you can also use node object itself
- in a range-based for construct, which is equivalent to using <code class="computeroutput"><span class="identifier">children</span><span class="special">()</span></code>.
- </p>
-<p>
- This is an example of using these functions (<a href="../samples/traverse_rangefor.cpp" target="_top">samples/traverse_rangefor.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span><span class="special">:</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">children</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool:"</span><span class="special">;</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span><span class="special">:</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attributes</span><span class="special">())</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span><span class="special">:</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">children</span><span class="special">())</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", child "</span> <span class="special">&lt;&lt;</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">name</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.iterators"></a><a class="link" href="access.html#manual.access.iterators" title="Traversing node/attribute lists via iterators"> Traversing node/attribute lists
- via iterators</a>
-</h3></div></div></div>
-<a name="xml_node_iterator"></a><a name="xml_attribute_iterator"></a><a name="xml_node::begin"></a><a name="xml_node::end"></a><a name="xml_node::attributes_begin"></a><a name="xml_node::attributes_end"></a><p>
- Child node lists and attribute lists are simply double-linked lists; while
- you can use <code class="computeroutput"><span class="identifier">previous_sibling</span></code>/<code class="computeroutput"><span class="identifier">next_sibling</span></code> and other such functions for
- iteration, pugixml additionally provides node and attribute iterators, so
- that you can treat nodes as containers of other nodes or attributes:
- </p>
-<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">xml_node_iterator</span><span class="special">;</span>
-<span class="keyword">class</span> <span class="identifier">xml_attribute_iterator</span><span class="special">;</span>
-
-<span class="keyword">typedef</span> <span class="identifier">xml_node_iterator</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">;</span>
-<span class="identifier">iterator</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">iterator</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-
-<span class="keyword">typedef</span> <span class="identifier">xml_attribute_iterator</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">attribute_iterator</span><span class="special">;</span>
-<span class="identifier">attribute_iterator</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">attributes_begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">attribute_iterator</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">attributes_end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">begin</span></code> and <code class="computeroutput"><span class="identifier">attributes_begin</span></code>
- return iterators that point to the first node/attribute, respectively; <code class="computeroutput"><span class="identifier">end</span></code> and <code class="computeroutput"><span class="identifier">attributes_end</span></code>
- return past-the-end iterator for node/attribute list, respectively - this
- iterator can't be dereferenced, but decrementing it results in an iterator
- pointing to the last element in the list (except for empty lists, where decrementing
- past-the-end iterator results in undefined behavior). Past-the-end iterator
- is commonly used as a termination value for iteration loops (see sample below).
- If you want to get an iterator that points to an existing handle, you can
- construct the iterator with the handle as a single constructor argument,
- like so: <code class="computeroutput"><span class="identifier">xml_node_iterator</span><span class="special">(</span><span class="identifier">node</span><span class="special">)</span></code>.
- For <code class="computeroutput"><span class="identifier">xml_attribute_iterator</span></code>,
- you'll have to provide both an attribute and its parent node.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">begin</span></code> and <code class="computeroutput"><span class="identifier">end</span></code>
- return equal iterators if called on null node; such iterators can't be dereferenced.
- <code class="computeroutput"><span class="identifier">attributes_begin</span></code> and <code class="computeroutput"><span class="identifier">attributes_end</span></code> behave the same way. For
- correct iterator usage this means that child node/attribute collections of
- null nodes appear to be empty.
- </p>
-<p>
- Both types of iterators have bidirectional iterator semantics (i.e. they
- can be incremented and decremented, but efficient random access is not supported)
- and support all usual iterator operations - comparison, dereference, etc.
- The iterators are invalidated if the node/attribute objects they're pointing
- to are removed from the tree; adding nodes/attributes does not invalidate
- any iterators.
- </p>
-<p>
- Here is an example of using iterators for document traversal (<a href="../samples/traverse_iter.cpp" target="_top">samples/traverse_iter.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool:"</span><span class="special">;</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute_iterator</span> <span class="identifier">ait</span> <span class="special">=</span> <span class="identifier">it</span><span class="special">-&gt;</span><span class="identifier">attributes_begin</span><span class="special">();</span> <span class="identifier">ait</span> <span class="special">!=</span> <span class="identifier">it</span><span class="special">-&gt;</span><span class="identifier">attributes_end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">ait</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span> <span class="special">&lt;&lt;</span> <span class="identifier">ait</span><span class="special">-&gt;</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">ait</span><span class="special">-&gt;</span><span class="identifier">value</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Node and attribute iterators are somewhere in the middle between const
- and non-const iterators. While dereference operation yields a non-constant
- reference to the object, so that you can use it for tree modification operations,
- modifying this reference by assignment - i.e. passing iterators to a function
- like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">sort</span></code> - will not give expected results,
- as assignment modifies local handle that's stored in the iterator.
- </p></td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.walker"></a><a class="link" href="access.html#manual.access.walker" title="Recursive traversal with xml_tree_walker"> Recursive traversal with xml_tree_walker</a>
-</h3></div></div></div>
-<a name="xml_tree_walker"></a><p>
- The methods described above allow traversal of immediate children of some
- node; if you want to do a deep tree traversal, you'll have to do it via a
- recursive function or some equivalent method. However, pugixml provides a
- helper for depth-first traversal of a subtree. In order to use it, you have
- to implement <code class="computeroutput"><span class="identifier">xml_tree_walker</span></code>
- interface and to call <code class="computeroutput"><span class="identifier">traverse</span></code>
- function:
- </p>
-<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">xml_tree_walker</span>
-<span class="special">{</span>
-<span class="keyword">public</span><span class="special">:</span>
- <span class="keyword">virtual</span> <span class="keyword">bool</span> <span class="identifier">begin</span><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
- <span class="keyword">virtual</span> <span class="keyword">bool</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
- <span class="keyword">virtual</span> <span class="keyword">bool</span> <span class="identifier">end</span><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-
- <span class="keyword">int</span> <span class="identifier">depth</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="special">};</span>
-
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">traverse</span><span class="special">(</span><span class="identifier">xml_tree_walker</span><span class="special">&amp;</span> <span class="identifier">walker</span><span class="special">);</span>
-</pre>
-<a name="xml_tree_walker::begin"></a><a name="xml_tree_walker::for_each"></a><a name="xml_tree_walker::end"></a><a name="xml_node::traverse"></a><p>
- The traversal is launched by calling <code class="computeroutput"><span class="identifier">traverse</span></code>
- function on traversal root and proceeds as follows:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- First, <code class="computeroutput"><span class="identifier">begin</span></code> function
- is called with traversal root as its argument.
- </li>
-<li class="listitem">
- Then, <code class="computeroutput"><span class="identifier">for_each</span></code> function
- is called for all nodes in the traversal subtree in depth first order,
- excluding the traversal root. Node is passed as an argument.
- </li>
-<li class="listitem">
- Finally, <code class="computeroutput"><span class="identifier">end</span></code> function
- is called with traversal root as its argument.
- </li>
-</ul></div>
-<p>
- If <code class="computeroutput"><span class="identifier">begin</span></code>, <code class="computeroutput"><span class="identifier">end</span></code>
- or any of the <code class="computeroutput"><span class="identifier">for_each</span></code> calls
- return <code class="computeroutput"><span class="keyword">false</span></code>, the traversal
- is terminated and <code class="computeroutput"><span class="keyword">false</span></code> is returned
- as the traversal result; otherwise, the traversal results in <code class="computeroutput"><span class="keyword">true</span></code>. Note that you don't have to override
- <code class="computeroutput"><span class="identifier">begin</span></code> or <code class="computeroutput"><span class="identifier">end</span></code>
- functions; their default implementations return <code class="computeroutput"><span class="keyword">true</span></code>.
- </p>
-<a name="xml_tree_walker::depth"></a><p>
- You can get the node's depth relative to the traversal root at any point
- by calling <code class="computeroutput"><span class="identifier">depth</span></code> function.
- It returns <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code>
- if called from <code class="computeroutput"><span class="identifier">begin</span></code>/<code class="computeroutput"><span class="identifier">end</span></code>, and returns 0-based depth if called
- from <code class="computeroutput"><span class="identifier">for_each</span></code> - depth is
- 0 for all children of the traversal root, 1 for all grandchildren and so
- on.
- </p>
-<p>
- This is an example of traversing tree hierarchy with xml_tree_walker (<a href="../samples/traverse_walker.cpp" target="_top">samples/traverse_walker.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">simple_walker</span><span class="special">:</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_tree_walker</span>
-<span class="special">{</span>
- <span class="keyword">virtual</span> <span class="keyword">bool</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">depth</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span> <span class="comment">// indentation
-</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node_types</span><span class="special">[</span><span class="identifier">node</span><span class="special">.</span><span class="identifier">type</span><span class="special">()]</span> <span class="special">&lt;&lt;</span> <span class="string">": name='"</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"', value='"</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"'\n"</span><span class="special">;</span>
-
- <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span> <span class="comment">// continue traversal
-</span> <span class="special">}</span>
-<span class="special">};</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">simple_walker</span> <span class="identifier">walker</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">traverse</span><span class="special">(</span><span class="identifier">walker</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.predicate"></a><a class="link" href="access.html#manual.access.predicate" title="Searching for nodes/attributes with predicates"> Searching for nodes/attributes
- with predicates</a>
-</h3></div></div></div>
-<a name="xml_node::find_attribute"></a><a name="xml_node::find_child"></a><a name="xml_node::find_node"></a><p>
- While there are existing functions for getting a node/attribute with known
- contents, they are often not sufficient for simple queries. As an alternative
- for manual iteration through nodes/attributes until the needed one is found,
- you can make a predicate and call one of <code class="computeroutput"><span class="identifier">find_</span></code>
- functions:
- </p>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">&gt;</span> <span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_attribute</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">&gt;</span> <span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">&gt;</span> <span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">find_node</span><span class="special">(</span><span class="identifier">Predicate</span> <span class="identifier">pred</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- The predicate should be either a plain function or a function object which
- accepts one argument of type <code class="computeroutput"><span class="identifier">xml_attribute</span></code>
- (for <code class="computeroutput"><span class="identifier">find_attribute</span></code>) or
- <code class="computeroutput"><span class="identifier">xml_node</span></code> (for <code class="computeroutput"><span class="identifier">find_child</span></code> and <code class="computeroutput"><span class="identifier">find_node</span></code>),
- and returns <code class="computeroutput"><span class="keyword">bool</span></code>. The predicate
- is never called with null handle as an argument.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">find_attribute</span></code> function iterates
- through all attributes of the specified node, and returns the first attribute
- for which the predicate returned <code class="computeroutput"><span class="keyword">true</span></code>.
- If the predicate returned <code class="computeroutput"><span class="keyword">false</span></code>
- for all attributes or if there were no attributes (including the case where
- the node is null), null attribute is returned.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">find_child</span></code> function iterates
- through all child nodes of the specified node, and returns the first node
- for which the predicate returned <code class="computeroutput"><span class="keyword">true</span></code>.
- If the predicate returned <code class="computeroutput"><span class="keyword">false</span></code>
- for all nodes or if there were no child nodes (including the case where the
- node is null), null node is returned.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">find_node</span></code> function performs
- a depth-first traversal through the subtree of the specified node (excluding
- the node itself), and returns the first node for which the predicate returned
- <code class="computeroutput"><span class="keyword">true</span></code>. If the predicate returned
- <code class="computeroutput"><span class="keyword">false</span></code> for all nodes or if subtree
- was empty, null node is returned.
- </p>
-<p>
- This is an example of using predicate-based functions (<a href="../samples/traverse_predicate.cpp" target="_top">samples/traverse_predicate.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">small_timeout</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="keyword">return</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Timeout"</span><span class="special">).</span><span class="identifier">as_int</span><span class="special">()</span> <span class="special">&lt;</span> <span class="number">20</span><span class="special">;</span>
-<span class="special">}</span>
-
-<span class="keyword">struct</span> <span class="identifier">allow_remote_predicate</span>
-<span class="special">{</span>
- <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span><span class="special">)</span> <span class="keyword">const</span>
- <span class="special">{</span>
- <span class="keyword">return</span> <span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">(),</span> <span class="string">"AllowRemote"</span><span class="special">)</span> <span class="special">==</span> <span class="number">0</span><span class="special">;</span>
- <span class="special">}</span>
-
- <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span><span class="special">)</span> <span class="keyword">const</span>
- <span class="special">{</span>
- <span class="keyword">return</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"AllowRemote"</span><span class="special">).</span><span class="identifier">as_bool</span><span class="special">();</span>
- <span class="special">}</span>
-<span class="special">};</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// Find child via predicate (looks for direct children only)
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// Find node via predicate (looks for all descendants in depth-first order)
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">find_node</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// Find attribute via predicate
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">find_attribute</span><span class="special">(</span><span class="identifier">allow_remote_predicate</span><span class="special">()).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// We can use simple functions instead of function objects
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child</span><span class="special">(</span><span class="identifier">small_timeout</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.text"></a><a class="link" href="access.html#manual.access.text" title="Working with text contents"> Working with text contents</a>
-</h3></div></div></div>
-<a name="xml_text"></a><p>
- It is common to store data as text contents of some node - i.e. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;&lt;</span><span class="identifier">description</span><span class="special">&gt;</span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special">&lt;/</span><span class="identifier">description</span><span class="special">&gt;&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>.
- In this case, <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">description</span><span class="special">&gt;</span></code> node does not have a value, but instead
- has a child of type <a class="link" href="dom.html#node_pcdata">node_pcdata</a> with value
- <code class="computeroutput"><span class="string">"This is a node"</span></code>. pugixml
- provides a special class, <code class="computeroutput"><span class="identifier">xml_text</span></code>,
- to work with such data. Working with text objects to modify data is described
- in <a class="link" href="modify.html#manual.modify.text" title="Working with text contents">the documentation for modifying document
- data</a>; this section describes the access interface of <code class="computeroutput"><span class="identifier">xml_text</span></code>.
- </p>
-<a name="xml_node::text"></a><p>
- You can get the text object from a node by using <code class="computeroutput"><span class="identifier">text</span><span class="special">()</span></code> method:
- </p>
-<pre class="programlisting"><span class="identifier">xml_text</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">text</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- If the node has a type <code class="computeroutput"><span class="identifier">node_pcdata</span></code>
- or <code class="computeroutput"><span class="identifier">node_cdata</span></code>, then the node
- itself is used to return data; otherwise, a first child node of type <code class="computeroutput"><span class="identifier">node_pcdata</span></code> or <code class="computeroutput"><span class="identifier">node_cdata</span></code>
- is used.
- </p>
-<a name="xml_text::empty"></a><a name="xml_text::unspecified_bool_type"></a><p>
- You can check if the text object is bound to a valid PCDATA/CDATA node by
- using it as a boolean value, i.e. <code class="computeroutput"><span class="keyword">if</span>
- <span class="special">(</span><span class="identifier">text</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span></code> or <code class="computeroutput"><span class="keyword">if</span>
- <span class="special">(!</span><span class="identifier">text</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span></code>. Alternatively you can check it
- by using the <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code>
- method:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<a name="xml_text::get"></a><p>
- Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA
- node) by using the following function:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- In case text object is empty, the function returns an empty string - it never
- returns a null pointer.
- </p>
-<a name="xml_text::as_string"></a><a name="xml_text::as_int"></a><a name="xml_text::as_uint"></a><a name="xml_text::as_double"></a><a name="xml_text::as_float"></a><a name="xml_text::as_bool"></a><a name="xml_text::as_llong"></a><a name="xml_text::as_ullong"></a><p>
- If you need a non-empty string if the text object is empty, or if the text
- contents is actually a number or a boolean that is stored as a string, you
- can use the following accessors:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_string</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">def</span> <span class="special">=</span> <span class="string">""</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">int</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_int</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_uint</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">double</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_double</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">float</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_float</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_bool</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_llong</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">as_ullong</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- All of the above functions have the same semantics as similar <code class="computeroutput"><span class="identifier">xml_attribute</span></code> members: they return the
- default argument if the text object is empty, they convert the text contents
- to a target type using the same rules and restrictions. You can <a class="link" href="access.html#xml_attribute::as_int">refer
- to documentation for the attribute functions</a> for details.
- </p>
-<a name="xml_text::data"></a><p>
- <code class="computeroutput"><span class="identifier">xml_text</span></code> is essentially a
- helper class that operates on <code class="computeroutput"><span class="identifier">xml_node</span></code>
- values. It is bound to a node of type <a class="link" href="dom.html#node_pcdata">node_pcdata</a>
- or <a class="link" href="dom.html#node_cdata">node_cdata</a>. You can use the following
- function to retrieve this node:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">data</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- Essentially, assuming <code class="computeroutput"><span class="identifier">text</span></code>
- is an <code class="computeroutput"><span class="identifier">xml_text</span></code> object, calling
- <code class="computeroutput"><span class="identifier">text</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span></code> is
- equivalent to calling <code class="computeroutput"><span class="identifier">text</span><span class="special">.</span><span class="identifier">data</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span></code>.
- </p>
-<p>
- This is an example of using <code class="computeroutput"><span class="identifier">xml_text</span></code>
- object (<a href="../samples/text.cpp" target="_top">samples/text.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Project name: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"name"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Project version: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"version"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">as_double</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Project visibility: "</span> <span class="special">&lt;&lt;</span> <span class="special">(</span><span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"public"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">as_bool</span><span class="special">(/*</span> <span class="identifier">def</span><span class="special">=</span> <span class="special">*/</span> <span class="keyword">true</span><span class="special">)</span> <span class="special">?</span> <span class="string">"public"</span> <span class="special">:</span> <span class="string">"private"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Project description: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"description"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">get</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.access.misc"></a><a class="link" href="access.html#manual.access.misc" title="Miscellaneous functions"> Miscellaneous functions</a>
-</h3></div></div></div>
-<a name="xml_node::root"></a><p>
- If you need to get the document root of some node, you can use the following
- function:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">root</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- This function returns the node with type <a class="link" href="dom.html#node_document">node_document</a>,
- which is the root node of the document the node belongs to (unless the node
- is null, in which case null node is returned).
- </p>
-<a name="xml_node::path"></a><a name="xml_node::first_element_by_path"></a><p>
- While pugixml supports complex XPath expressions, sometimes a simple path
- handling facility is needed. There are two functions, for getting node path
- and for converting path to a node:
- </p>
-<pre class="programlisting"><span class="identifier">string_t</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">path</span><span class="special">(</span><span class="identifier">char_t</span> <span class="identifier">delimiter</span> <span class="special">=</span> <span class="char">'/'</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">first_element_by_path</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="identifier">char_t</span> <span class="identifier">delimiter</span> <span class="special">=</span> <span class="char">'/'</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- Node paths consist of node names, separated with a delimiter (which is <code class="computeroutput"><span class="special">/</span></code> by default); also paths can contain self
- (<code class="computeroutput"><span class="special">.</span></code>) and parent (<code class="computeroutput"><span class="special">..</span></code>) pseudo-names, so that this is a valid
- path: <code class="computeroutput"><span class="string">"../../foo/./bar"</span></code>.
- <code class="computeroutput"><span class="identifier">path</span></code> returns the path to
- the node from the document root, <code class="computeroutput"><span class="identifier">first_element_by_path</span></code>
- looks for a node represented by a given path; a path can be an absolute one
- (absolute paths start with the delimiter), in which case the rest of the
- path is treated as document root relative, and relative to the given node.
- For example, in the following document: <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">&gt;&lt;</span><span class="identifier">b</span><span class="special">&gt;&lt;</span><span class="identifier">c</span><span class="special">/&gt;&lt;/</span><span class="identifier">b</span><span class="special">&gt;&lt;/</span><span class="identifier">a</span><span class="special">&gt;</span></code>,
- node <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">c</span><span class="special">/&gt;</span></code> has path <code class="computeroutput"><span class="string">"a/b/c"</span></code>;
- calling <code class="computeroutput"><span class="identifier">first_element_by_path</span></code>
- for document with path <code class="computeroutput"><span class="string">"a/b"</span></code>
- results in node <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">b</span><span class="special">/&gt;</span></code>; calling <code class="computeroutput"><span class="identifier">first_element_by_path</span></code>
- for node <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">/&gt;</span></code> with path <code class="computeroutput"><span class="string">"../a/./b/../."</span></code>
- results in node <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">/&gt;</span></code>; calling <code class="computeroutput"><span class="identifier">first_element_by_path</span></code>
- with path <code class="computeroutput"><span class="string">"/a"</span></code> results
- in node <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">/&gt;</span></code> for any node.
- </p>
-<p>
- In case path component is ambiguous (if there are two nodes with given name),
- the first one is selected; paths are not guaranteed to uniquely identify
- nodes in a document. If any component of a path is not found, the result
- of <code class="computeroutput"><span class="identifier">first_element_by_path</span></code>
- is null node; also <code class="computeroutput"><span class="identifier">first_element_by_path</span></code>
- returns null node for null nodes, in which case the path does not matter.
- <code class="computeroutput"><span class="identifier">path</span></code> returns an empty string
- for null nodes.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- <code class="computeroutput"><span class="identifier">path</span></code> function returns the
- result as STL string, and thus is not available if <a class="link" href="install.html#PUGIXML_NO_STL">PUGIXML_NO_STL</a>
- is defined.
- </p></td></tr>
-</table></div>
-<a name="xml_node::offset_debug"></a><p>
- pugixml does not record row/column information for nodes upon parsing for
- efficiency reasons. However, if the node has not changed in a significant
- way since parsing (the name/value are not changed, and the node itself is
- the original one, i.e. it was not deleted from the tree and re-added later),
- it is possible to get the offset from the beginning of XML buffer:
- </p>
-<pre class="programlisting"><span class="identifier">ptrdiff_t</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">offset_debug</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- If the offset is not available (this happens if the node is null, was not
- originally parsed from a stream, or has changed in a significant way), the
- function returns -1. Otherwise it returns the offset to node's data from
- the beginning of XML buffer in <a class="link" href="dom.html#char_t">pugi::char_t</a>
- units. For more information on parsing offsets, see <a class="link" href="loading.html#xml_parse_result::offset">parsing
- error handling documentation</a>.
- </p>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <b>Accessing</b> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="loading.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="modify.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/apiref.html b/docs/manual/apiref.html
deleted file mode 100644
index b9cbc77..0000000
--- a/docs/manual/apiref.html
+++ /dev/null
@@ -1,1664 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>API Reference</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="changes.html" title="Changelog">
-<link rel="next" href="toc.html" title="Table of Contents">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <b>API Reference</b> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="changes.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="toc.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.apiref"></a><a class="link" href="apiref.html" title="API Reference"> API Reference</a>
-</h2></div></div></div>
-<p>
- This is the reference for all macros, types, enumerations, classes and functions
- in pugixml. Each symbol is a link that leads to the relevant section of the
- manual.
- </p>
-<p>
- Macros:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_NO_XPATH">PUGIXML_NO_XPATH</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_NO_STL">PUGIXML_NO_STL</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_API">PUGIXML_API</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_CLASS">PUGIXML_CLASS</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_FUNCTION">PUGIXML_FUNCTION</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_MEMORY_PAGE_SIZE">PUGIXML_MEMORY_PAGE_SIZE</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_MEMORY_OUTPUT_STACK">PUGIXML_MEMORY_OUTPUT_STACK</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_MEMORY_XPATH_PAGE_SIZE">PUGIXML_MEMORY_XPATH_PAGE_SIZE</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_HEADER_ONLY">PUGIXML_HEADER_ONLY</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="preprocessor">#define</span> </code><a class="link" href="install.html#PUGIXML_HAS_LONG_LONG">PUGIXML_HAS_LONG_LONG</a>
- </li>
-</ul></div>
-<p>
- Types:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> </code><span class="emphasis"><em>configuration-defined
- type</em></span><code class="computeroutput"> </code><a class="link" href="dom.html#char_t">char_t</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> </code><span class="emphasis"><em>configuration-defined
- type</em></span><code class="computeroutput"> </code><a class="link" href="dom.html#string_t">string_t</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> <span class="keyword">void</span><span class="special">*</span> <span class="special">(*</span></code><a class="link" href="dom.html#allocation_function">allocation_function</a><code class="computeroutput"><span class="special">)(</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> <span class="keyword">void</span>
- <span class="special">(*</span></code><a class="link" href="dom.html#deallocation_function">deallocation_function</a><code class="computeroutput"><span class="special">)(</span><span class="keyword">void</span><span class="special">*</span>
- <span class="identifier">ptr</span><span class="special">);</span></code>
- </li>
-</ul></div>
-<p>
- Enumerations:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="dom.html#xml_node_type">xml_node_type</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="dom.html#node_null">node_null</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_document">node_document</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_element">node_element</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_pcdata">node_pcdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_cdata">node_cdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_comment">node_comment</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_pi">node_pi</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_declaration">node_declaration</a>
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_doctype">node_doctype</a> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="loading.html#xml_parse_status">xml_parse_status</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="loading.html#status_ok">status_ok</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_file_not_found">status_file_not_found</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_io_error">status_io_error</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_out_of_memory">status_out_of_memory</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_internal_error">status_internal_error</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_unrecognized_tag">status_unrecognized_tag</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_pi">status_bad_pi</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_comment">status_bad_comment</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_cdata">status_bad_cdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_doctype">status_bad_doctype</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_pcdata">status_bad_pcdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_start_element">status_bad_start_element</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_attribute">status_bad_attribute</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_bad_end_element">status_bad_end_element</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_end_element_mismatch">status_end_element_mismatch</a>
- </li>
-<li class="listitem">
- <a class="link" href="modify.html#status_append_invalid_root">status_append_invalid_root</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#status_no_document_element">status_no_document_element</a>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="loading.html#xml_encoding">xml_encoding</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="loading.html#encoding_auto">encoding_auto</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf8">encoding_utf8</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf16_le">encoding_utf16_le</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf16_be">encoding_utf16_be</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf16">encoding_utf16</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf32_le">encoding_utf32_le</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf32_be">encoding_utf32_be</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_utf32">encoding_utf32</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_wchar">encoding_wchar</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#encoding_latin1">encoding_latin1</a> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">enum</span> </code><a class="link" href="xpath.html#xpath_value_type">xpath_value_type</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_type_none">xpath_type_none</a>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_type_node_set">xpath_type_node_set</a>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_type_number">xpath_type_number</a>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_type_string">xpath_type_string</a>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_type_boolean">xpath_type_boolean</a>
- </li>
-</ul></div>
- </li>
-</ul></div>
-<p>
- Constants:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Formatting options bit flags:
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="saving.html#format_default">format_default</a>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#format_indent">format_indent</a>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#format_no_declaration">format_no_declaration</a>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#format_no_escapes">format_no_escapes</a>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#format_raw">format_raw</a>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#format_save_file_text">format_save_file_text</a>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#format_write_bom">format_write_bom</a> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- Parsing options bit flags:
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="loading.html#parse_cdata">parse_cdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_comments">parse_comments</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_declaration">parse_declaration</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_default">parse_default</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_doctype">parse_doctype</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_eol">parse_eol</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_escapes">parse_escapes</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_fragment">parse_fragment</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_full">parse_full</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_minimal">parse_minimal</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_pi">parse_pi</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_trim_pcdata">parse_trim_pcdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_ws_pcdata_single">parse_ws_pcdata_single</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_wconv_attribute">parse_wconv_attribute</a>
- </li>
-<li class="listitem">
- <a class="link" href="loading.html#parse_wnorm_attribute">parse_wnorm_attribute</a>
- </li>
-</ul></div>
- </li>
-</ul></div>
-<p>
- Classes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="dom.html#xml_attribute">xml_attribute</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="dom.html#xml_attribute::ctor">xml_attribute</a><code class="computeroutput"><span class="special">();</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="dom.html#xml_attribute::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator==</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator!=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator&lt;</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator&gt;</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator&lt;=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_attribute::comparison">operator&gt;=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">size_t</span> </code><a class="link" href="dom.html#xml_attribute::hash_value">hash_value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_attribute::next_attribute">next_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_attribute::previous_attribute">previous_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_attribute::name">name</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_attribute::value">value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_attribute::as_string">as_string</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">def</span> <span class="special">=</span>
- <span class="string">""</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">int</span> </code><a class="link" href="access.html#xml_attribute::as_int">as_int</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span>
- </code><a class="link" href="access.html#xml_attribute::as_uint">as_uint</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">def</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">double</span> </code><a class="link" href="access.html#xml_attribute::as_double">as_double</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">float</span> </code><a class="link" href="access.html#xml_attribute::as_float">as_float</a><code class="computeroutput"><span class="special">(</span><span class="keyword">float</span> <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_attribute::as_bool">as_bool</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span>
- <span class="keyword">false</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span>
- </code><a class="link" href="access.html#xml_attribute::as_llong">as_llong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span>
- <span class="keyword">long</span> </code><a class="link" href="access.html#xml_attribute::as_ullong">as_ullong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">long</span> <span class="keyword">long</span>
- <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_name">set_name</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_attribute::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">long</span> <span class="keyword">long</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_attribute::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="identifier">unsnigned</span>
- <span class="keyword">long</span> <span class="keyword">long</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="dom.html#xml_node">xml_node</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="dom.html#xml_node::ctor">xml_node</a><code class="computeroutput"><span class="special">();</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="dom.html#xml_node::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator==</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator!=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator&lt;</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator&gt;</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator&lt;=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="dom.html#xml_node::comparison">operator&gt;=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">r</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">size_t</span> </code><a class="link" href="dom.html#xml_node::hash_value">hash_value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node_type</span> </code><a class="link" href="dom.html#xml_node::type">type</a><code class="computeroutput"><span class="special">()</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::name">name</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::value">value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::parent">parent</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::first_child">first_child</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::last_child">last_child</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::next_sibling">next_sibling</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::previous_sibling">previous_sibling</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_node::first_attribute">first_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_node::last_attribute">last_attribute</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <span class="emphasis"><em>implementation-defined type</em></span> <a class="link" href="access.html#xml_node::children">children</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <span class="emphasis"><em>implementation-defined type</em></span> <a class="link" href="access.html#xml_node::children">children</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <span class="emphasis"><em>implementation-defined type</em></span> <a class="link" href="access.html#xml_node::attributes">attributes</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::child">child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="access.html#xml_node::attribute">attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::next_sibling_name">next_sibling</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::previous_sibling_name">previous_sibling</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::find_child_by_attribute">find_child_by_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_name</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">attr_value</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::find_child_by_attribute">find_child_by_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">attr_name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">attr_value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::child_value">child_value</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_node::child_value">child_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span> </code><a class="link" href="access.html#xml_node::text">text</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">xml_node_iterator</span>
- </code><a class="link" href="access.html#xml_node_iterator">iterator</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">iterator</span> </code><a class="link" href="access.html#xml_node::begin">begin</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">iterator</span> </code><a class="link" href="access.html#xml_node::end">end</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">xml_attribute_iterator</span>
- </code><a class="link" href="access.html#xml_attribute_iterator">attribute_iterator</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">attribute_iterator</span> </code><a class="link" href="access.html#xml_node::attributes_begin">attributes_begin</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">attribute_iterator</span> </code><a class="link" href="access.html#xml_node::attributes_end">attributes_end</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_node::traverse">traverse</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_tree_walker</span><span class="special">&amp;</span> <span class="identifier">walker</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">&gt;</span> <span class="identifier">xml_attribute</span>
- </code><a class="link" href="access.html#xml_node::find_attribute">find_attribute</a><code class="computeroutput"><span class="special">(</span><span class="identifier">Predicate</span>
- <span class="identifier">pred</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">&gt;</span> <span class="identifier">xml_node</span>
- </code><a class="link" href="access.html#xml_node::find_child">find_child</a><code class="computeroutput"><span class="special">(</span><span class="identifier">Predicate</span>
- <span class="identifier">pred</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Predicate</span><span class="special">&gt;</span> <span class="identifier">xml_node</span>
- </code><a class="link" href="access.html#xml_node::find_node">find_node</a><code class="computeroutput"><span class="special">(</span><span class="identifier">Predicate</span>
- <span class="identifier">pred</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">string_t</span> </code><a class="link" href="access.html#xml_node::path">path</a><code class="computeroutput"><span class="special">(</span><span class="identifier">char_t</span>
- <span class="identifier">delimiter</span> <span class="special">=</span>
- <span class="char">'/'</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::first_element_by_path">xml_node::first_element_by_path</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">path</span><span class="special">,</span>
- <span class="identifier">char_t</span> <span class="identifier">delimiter</span>
- <span class="special">=</span> <span class="char">'/'</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_node::root">root</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">ptrdiff_t</span> </code><a class="link" href="access.html#xml_node::offset_debug">offset_debug</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::set_name">set_name</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::set_value">set_value</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::append_attribute">append_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::prepend_attribute">prepend_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::insert_attribute_after">insert_attribute_after</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::insert_attribute_before">insert_attribute_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_child">append_child</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node_type</span>
- <span class="identifier">type</span> <span class="special">=</span>
- <span class="identifier">node_element</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::prepend_child">prepend_child</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node_type</span>
- <span class="identifier">type</span> <span class="special">=</span>
- <span class="identifier">node_element</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_child_after">insert_child_after</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node_type</span>
- <span class="identifier">type</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_child_before">insert_child_before</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node_type</span>
- <span class="identifier">type</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_child">append_child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::prepend_child">prepend_child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_child_after">insert_child_after</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_child_before">insert_child_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::append_copy">append_copy</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::prepend_copy">prepend_copy</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::insert_copy_after">insert_copy_after</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="modify.html#xml_node::insert_copy_before">insert_copy_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_copy">append_copy</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::prepend_copy">prepend_copy</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_copy_after">insert_copy_after</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_copy_before">insert_copy_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::append_move">append_move</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">moved</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::prepend_move">prepend_move</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">moved</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_move_after">insert_move_after</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">moved</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="modify.html#xml_node::insert_move_before">insert_move_before</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">moved</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::remove_attribute">remove_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span>
- <span class="identifier">a</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::remove_attribute">remove_attribute</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::remove_child">remove_child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_node::remove_child">remove_child</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="modify.html#xml_node::append_buffer">append_buffer</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span>
- <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">options</span>
- <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span>
- <span class="identifier">encoding</span> <span class="special">=</span>
- <span class="identifier">encoding_auto</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_node::print">print</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_writer</span><span class="special">&amp;</span> <span class="identifier">writer</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">indent</span> <span class="special">=</span>
- <span class="string">"\t"</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">flags</span> <span class="special">=</span>
- <span class="identifier">format_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">depth</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_node::print_stream">print</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">indent</span> <span class="special">=</span>
- <span class="string">"\t"</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">flags</span> <span class="special">=</span>
- <span class="identifier">format_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">depth</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_node::print_stream">print</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wostream</span><span class="special">&amp;</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">indent</span> <span class="special">=</span>
- <span class="string">"\t"</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">flags</span> <span class="special">=</span>
- <span class="identifier">format_default</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">depth</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node</span> </code><a class="link" href="xpath.html#xml_node::select_node">select_node</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node</span> </code><a class="link" href="xpath.html#xml_node::select_node_precomp">select_node</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_query</span><span class="special">&amp;</span>
- <span class="identifier">query</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node_set</span> </code><a class="link" href="xpath.html#xml_node::select_nodes">select_nodes</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">query</span><span class="special">,</span>
- <span class="identifier">xpath_variable_set</span><span class="special">*</span>
- <span class="identifier">variables</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node_set</span> </code><a class="link" href="xpath.html#xml_node::select_nodes_precomp">select_nodes</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_query</span><span class="special">&amp;</span>
- <span class="identifier">query</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="dom.html#xml_document">xml_document</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="dom.html#xml_document::ctor">xml_document</a><code class="computeroutput"><span class="special">();</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="special">~</span></code><a class="link" href="dom.html#xml_document::dtor">xml_document</a><code class="computeroutput"><span class="special">();</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="dom.html#xml_document::reset">reset</a><code class="computeroutput"><span class="special">();</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="dom.html#xml_document::reset">reset</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_document</span><span class="special">&amp;</span>
- <span class="identifier">proto</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_stream">load</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&amp;</span>
- <span class="identifier">stream</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">options</span> <span class="special">=</span>
- <span class="identifier">parse_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_stream">load</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wistream</span><span class="special">&amp;</span>
- <span class="identifier">stream</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">options</span> <span class="special">=</span>
- <span class="identifier">parse_default</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_string">load_string</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">contents</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">options</span> <span class="special">=</span>
- <span class="identifier">parse_default</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_file">load_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">options</span>
- <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span>
- <span class="identifier">encoding</span> <span class="special">=</span>
- <span class="identifier">encoding_auto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_file_wide">load_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span>
- <span class="identifier">path</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">options</span> <span class="special">=</span>
- <span class="identifier">parse_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_buffer">load_buffer</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span>
- <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">options</span>
- <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span>
- <span class="identifier">encoding</span> <span class="special">=</span>
- <span class="identifier">encoding_auto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_buffer_inplace">load_buffer_inplace</a><code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span>
- <span class="identifier">size</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">options</span> <span class="special">=</span>
- <span class="identifier">parse_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_result</span> </code><a class="link" href="loading.html#xml_document::load_buffer_inplace_own">load_buffer_inplace_own</a><code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span>
- <span class="identifier">size</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">options</span> <span class="special">=</span>
- <span class="identifier">parse_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="saving.html#xml_document::save_file">save_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span>
- <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">flags</span>
- <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span>
- <span class="identifier">encoding</span> <span class="special">=</span>
- <span class="identifier">encoding_auto</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="saving.html#xml_document::save_file_wide">save_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span>
- <span class="identifier">path</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span>
- <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">flags</span>
- <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span>
- <span class="identifier">encoding</span> <span class="special">=</span>
- <span class="identifier">encoding_auto</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_document::save_stream">save</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">indent</span> <span class="special">=</span>
- <span class="string">"\t"</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">flags</span> <span class="special">=</span>
- <span class="identifier">format_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_document::save_stream">save</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wostream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">indent</span> <span class="special">=</span>
- <span class="string">"\t"</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">flags</span> <span class="special">=</span>
- <span class="identifier">format_default</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="saving.html#xml_document::save">save</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_writer</span><span class="special">&amp;</span> <span class="identifier">writer</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">indent</span> <span class="special">=</span>
- <span class="string">"\t"</span><span class="special">,</span>
- <span class="keyword">unsigned</span> <span class="keyword">int</span>
- <span class="identifier">flags</span> <span class="special">=</span>
- <span class="identifier">format_default</span><span class="special">,</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span>
- <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="dom.html#xml_document::document_element">document_element</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">struct</span> </code><a class="link" href="loading.html#xml_parse_result">xml_parse_result</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_parse_status</span> </code><a class="link" href="loading.html#xml_parse_result::status">status</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">ptrdiff_t</span> </code><a class="link" href="loading.html#xml_parse_result::offset">offset</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_encoding</span> </code><a class="link" href="loading.html#xml_parse_result::encoding">encoding</a><code class="computeroutput"><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="loading.html#xml_parse_result::bool">bool</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="loading.html#xml_parse_result::description">description</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_node_iterator">xml_node_iterator</a>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_attribute_iterator">xml_attribute_iterator</a>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_tree_walker">xml_tree_walker</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">bool</span>
- </code><a class="link" href="access.html#xml_tree_walker::begin">begin</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">bool</span>
- </code><a class="link" href="access.html#xml_tree_walker::for_each">for_each</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">bool</span>
- </code><a class="link" href="access.html#xml_tree_walker::end">end</a><code class="computeroutput"><span class="special">(</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">int</span> </code><a class="link" href="access.html#xml_tree_walker::depth">depth</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="access.html#xml_text">xml_text</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_text::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="access.html#xml_text::unspecified_bool_type">xml_text::unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_text::get">xml_text::get</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="access.html#xml_text::as_string">as_string</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">def</span> <span class="special">=</span>
- <span class="string">""</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">int</span> </code><a class="link" href="access.html#xml_text::as_int">as_int</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">int</span>
- </code><a class="link" href="access.html#xml_text::as_uint">as_uint</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">def</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">double</span> </code><a class="link" href="access.html#xml_text::as_double">as_double</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">float</span> </code><a class="link" href="access.html#xml_text::as_float">as_float</a><code class="computeroutput"><span class="special">(</span><span class="keyword">float</span> <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="access.html#xml_text::as_bool">as_bool</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">def</span> <span class="special">=</span>
- <span class="keyword">false</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span>
- </code><a class="link" href="access.html#xml_text::as_llong">as_llong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">def</span>
- <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span>
- <span class="keyword">long</span> </code><a class="link" href="access.html#xml_text::as_ullong">as_ullong</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">long</span> <span class="keyword">long</span>
- <span class="identifier">def</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="modify.html#xml_text::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">long</span> <span class="keyword">long</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_text</span><span class="special">&amp;</span>
- </code><a class="link" href="modify.html#xml_text::assign">operator=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">unsigned</span>
- <span class="keyword">long</span> <span class="keyword">long</span>
- <span class="identifier">rhs</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="access.html#xml_text::data">data</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="saving.html#xml_writer">xml_writer</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
- <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">void</span>
- </code><a class="link" href="saving.html#xml_writer::write">write</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">data</span><span class="special">,</span>
- <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span></code>
- <br><br>
-
- </li></ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="saving.html#xml_writer_file">xml_writer_file</a><code class="computeroutput"><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">xml_writer</span></code>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem">
- <a class="link" href="saving.html#xml_writer_file">xml_writer_file</a><code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">file</span><span class="special">);</span></code> <br><br>
-
- </li></ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="saving.html#xml_writer_stream">xml_writer_stream</a><code class="computeroutput"><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">xml_writer</span></code>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="saving.html#xml_writer_stream">xml_writer_stream</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <a class="link" href="saving.html#xml_writer_stream">xml_writer_stream</a><code class="computeroutput"><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wostream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">);</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">struct</span> </code><a class="link" href="xpath.html#xpath_parse_result">xpath_parse_result</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_parse_result::error">error</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">ptrdiff_t</span> </code><a class="link" href="xpath.html#xpath_parse_result::offset">offset</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="xpath.html#xpath_parse_result::bool">bool</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_parse_result::description">description</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_query">xpath_query</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">explicit</span> </code><a class="link" href="xpath.html#xpath_query::ctor">xpath_query</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">query</span><span class="special">,</span>
- <span class="identifier">xpath_variable_set</span><span class="special">*</span>
- <span class="identifier">variables</span> <span class="special">=</span>
- <span class="number">0</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_boolean">evaluate_boolean</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">double</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_number">evaluate_number</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">string_t</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_string">evaluate_string</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">size_t</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_string_buffer">evaluate_string</a><code class="computeroutput"><span class="special">(</span><span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size_t</span>
- <span class="identifier">capacity</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node_set</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_node_set">evaluate_node_set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node</span> </code><a class="link" href="xpath.html#xpath_query::evaluate_node">evaluate_node</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_value_type</span> </code><a class="link" href="xpath.html#xpath_query::return_type">return_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&amp;</span> </code><a class="link" href="xpath.html#xpath_query::result">result</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="xpath.html#xpath_query::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_exception">xpath_exception</a><code class="computeroutput"><span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exception</span></code>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">virtual</span> <span class="keyword">const</span>
- <span class="keyword">char</span><span class="special">*</span>
- </code><a class="link" href="xpath.html#xpath_exception::what">what</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span>
- <span class="keyword">throw</span><span class="special">();</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&amp;</span> </code><a class="link" href="xpath.html#xpath_exception::result">result</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_node">xpath_node</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_node::ctor">xpath_node</a><code class="computeroutput"><span class="special">();</span></code>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_node::ctor">xpath_node</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_node::ctor">xpath_node</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attribute</span><span class="special">,</span> <span class="keyword">const</span>
- <span class="identifier">xml_node</span><span class="special">&amp;</span>
- <span class="identifier">parent</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="xpath.html#xpath_node::node">node</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_attribute</span> </code><a class="link" href="xpath.html#xpath_node::attribute">attribute</a><code class="computeroutput"><span class="special">()</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xml_node</span> </code><a class="link" href="xpath.html#xpath_node::parent">parent</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">operator</span> </code><a class="link" href="xpath.html#xpath_node::unspecified_bool_type">unspecified_bool_type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_node::comparison">operator==</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_node::comparison">operator!=</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span>
- <span class="identifier">n</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_node_set">xpath_node_set</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_node_set::ctor">xpath_node_set</a><code class="computeroutput"><span class="special">();</span></code>
- </li>
-<li class="listitem">
- <a class="link" href="xpath.html#xpath_node_set::ctor">xpath_node_set</a><code class="computeroutput"><span class="special">(</span><span class="identifier">const_iterator</span>
- <span class="identifier">begin</span><span class="special">,</span>
- <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">,</span> <span class="identifier">type_t</span>
- <span class="identifier">type</span> <span class="special">=</span>
- <span class="identifier">type_unsorted</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">typedef</span> <span class="keyword">const</span>
- <span class="identifier">xpath_node</span><span class="special">*</span>
- </code><a class="link" href="xpath.html#xpath_node_set::const_iterator">const_iterator</a><code class="computeroutput"><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">const_iterator</span> </code><a class="link" href="xpath.html#xpath_node_set::begin">begin</a><code class="computeroutput"><span class="special">()</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">const_iterator</span> </code><a class="link" href="xpath.html#xpath_node_set::end">end</a><code class="computeroutput"><span class="special">()</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> </code><a class="link" href="xpath.html#xpath_node_set::index">operator[]</a><code class="computeroutput"><span class="special">(</span><span class="identifier">size_t</span>
- <span class="identifier">index</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">size_t</span> </code><a class="link" href="xpath.html#xpath_node_set::size">size</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_node_set::empty">empty</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_node</span> </code><a class="link" href="xpath.html#xpath_node_set::first">first</a><code class="computeroutput"><span class="special">()</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">enum</span> <span class="identifier">type_t</span>
- <span class="special">{</span></code><a class="link" href="xpath.html#xpath_node_set::type_unsorted">type_unsorted</a>,
- <a class="link" href="xpath.html#xpath_node_set::type_sorted">type_sorted</a>,
- <a class="link" href="xpath.html#xpath_node_set::type_sorted_reverse">type_sorted_reverse</a><code class="computeroutput"><span class="special">};</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">type_t</span> </code><a class="link" href="xpath.html#xpath_node_set::type">type</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="xpath.html#xpath_node_set::sort">sort</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">reverse</span> <span class="special">=</span>
- <span class="keyword">false</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_variable">xpath_variable</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_variable::name">name</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_value_type</span> </code><a class="link" href="xpath.html#xpath_variable::type">type</a><code class="computeroutput"><span class="special">()</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::get_boolean">get_boolean</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">double</span> </code><a class="link" href="xpath.html#xpath_variable::get_number">get_number</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_variable::get_string">get_string</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&amp;</span> </code><a class="link" href="xpath.html#xpath_variable::get_node_set">get_node_set</a><code class="computeroutput"><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">double</span>
- <span class="identifier">value</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">value</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&amp;</span>
- <span class="identifier">value</span><span class="special">);</span></code>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">class</span> </code><a class="link" href="xpath.html#xpath_variable_set">xpath_variable_set</a>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_variable</span><span class="special">*</span>
- </code><a class="link" href="xpath.html#xpath_variable_set::add">add</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="identifier">xpath_value_type</span> <span class="identifier">type</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable_set::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable_set::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">double</span> <span class="identifier">value</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable_set::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">value</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">bool</span> </code><a class="link" href="xpath.html#xpath_variable_set::set">set</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">,</span>
- <span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">);</span></code> <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">xpath_variable</span><span class="special">*</span>
- </code><a class="link" href="xpath.html#xpath_variable_set::get">get</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_variable</span><span class="special">*</span> </code><a class="link" href="xpath.html#xpath_variable_set::get">get</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span>
- <span class="identifier">name</span><span class="special">)</span>
- <span class="keyword">const</span><span class="special">;</span></code>
- <br><br>
-
- </li>
-</ul></div>
- </li>
-</ul></div>
-<p>
- Functions:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> </code><a class="link" href="dom.html#as_utf8">as_utf8</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> </code><a class="link" href="dom.html#as_utf8">as_utf8</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span><span class="special">&amp;</span>
- <span class="identifier">str</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span> </code><a class="link" href="dom.html#as_wide">as_wide</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span> </code><a class="link" href="dom.html#as_wide">as_wide</a><code class="computeroutput"><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span>
- <span class="identifier">str</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="keyword">void</span> </code><a class="link" href="dom.html#set_memory_management_functions">set_memory_management_functions</a><code class="computeroutput"><span class="special">(</span><span class="identifier">allocation_function</span>
- <span class="identifier">allocate</span><span class="special">,</span>
- <span class="identifier">deallocation_function</span> <span class="identifier">deallocate</span><span class="special">);</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">allocation_function</span> </code><a class="link" href="dom.html#get_memory_allocation_function">get_memory_allocation_function</a><code class="computeroutput"><span class="special">();</span></code>
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">deallocation_function</span> </code><a class="link" href="dom.html#get_memory_deallocation_function">get_memory_deallocation_function</a><code class="computeroutput"><span class="special">();</span></code>
- </li>
-</ul></div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <b>API Reference</b> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="changes.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="toc.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/changes.html b/docs/manual/changes.html
deleted file mode 100644
index a3495b2..0000000
--- a/docs/manual/changes.html
+++ /dev/null
@@ -1,1064 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Changelog</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="xpath.html" title="XPath">
-<link rel="next" href="apiref.html" title="API Reference">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="xpath.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="apiref.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.changes"></a><a class="link" href="changes.html" title="Changelog"> Changelog</a>
-</h2></div></div></div>
-<a name="manual.changes.27_11_2014___version_1_5"></a><h6>
- <a class="link" href="changes.html#manual.changes.27_11_2014___version_1_5">27.11.2014 - version
- 1.5</a>
- </h6>
-<p>
- Major release, featuring a lot of performance improvements and some new features.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Specification changes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- xml_document::load(const char_t*) was renamed to load_string; the
- old method is still available and will be deprecated in a future
- release
- </li>
-<li class="listitem">
- xml_node::select_single_node was renamed to select_node; the old
- method is still available and will be deprecated in a future release.
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added xml_node::append_move and other functions for moving nodes
- within a document
- </li>
-<li class="listitem">
- Added xpath_query::evaluate_node for evaluating queries with a single
- node as a result
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Performance improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Optimized XML parsing (10-40% faster with clang/gcc, up to 10% faster
- with MSVC)
- </li>
-<li class="listitem">
- Optimized memory consumption when copying nodes in the same document
- (string contents is now shared)
- </li>
-<li class="listitem">
- Optimized node copying (10% faster for cross-document copies, 3x
- faster for inter-document copies; also it now consumes a constant
- amount of stack space)
- </li>
-<li class="listitem">
- Optimized node output (60% faster; also it now consumes a constant
- amount of stack space)
- </li>
-<li class="listitem">
- Optimized XPath allocation (query evaluation now results in fewer
- temporary allocations)
- </li>
-<li class="listitem">
- Optimized XPath sorting (node set sorting is 2-3x faster in some
- cases)
- </li>
-<li class="listitem">
- Optimized XPath evaluation (XPathMark suite is 100x faster; some
- commonly used queries are 3-4x faster)
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Compatibility improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed xml_node::offset_debug for corner cases
- </li>
-<li class="listitem">
- Fixed undefined behavior while calling memcpy in some cases
- </li>
-<li class="listitem">
- Fixed MSVC 2015 compilation warnings
- </li>
-<li class="listitem">
- Fixed contrib/foreach.hpp for Boost 1.56.0
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Bug fixes
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Adjusted comment output to avoid malformed documents if the comment
- value contains "--"
- </li>
-<li class="listitem">
- Fix XPath sorting for documents that were constructed using append_buffer
- </li>
-<li class="listitem">
- Fix load_file for wide-character paths with non-ASCII characters
- in MinGW with C++11 mode enabled
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.27_02_2014___version_1_4"></a><h6>
- <a class="link" href="changes.html#manual.changes.27_02_2014___version_1_4">27.02.2014 - version
- 1.4</a>
- </h6>
-<p>
- Major release, featuring various new features, bug fixes and compatibility
- improvements.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Specification changes:
- <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
- Documents without element nodes are now rejected with status_no_document_element
- error, unless parse_fragment option is used
- </li></ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added XML fragment parsing (parse_fragment flag)
- </li>
-<li class="listitem">
- Added PCDATA whitespace trimming (parse_trim_pcdata flag)
- </li>
-<li class="listitem">
- Added long long support for xml_attribute and xml_text (as_llong,
- as_ullong and set_value/set overloads)
- </li>
-<li class="listitem">
- Added hexadecimal integer parsing support for as_int/as_uint/as_llong/as_ullong
- </li>
-<li class="listitem">
- Added xml_node::append_buffer to improve performance of assembling
- documents from fragments
- </li>
-<li class="listitem">
- xml_named_node_iterator is now bidirectional
- </li>
-<li class="listitem">
- Reduced XPath stack consumption during compilation and evaluation
- (useful for embedded systems)
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Compatibility improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Improved support for platforms without wchar_t support
- </li>
-<li class="listitem">
- Fixed several false positives in clang static analysis
- </li>
-<li class="listitem">
- Fixed several compilation warnings for various GCC versions
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed undefined pointer arithmetic in XPath implementation
- </li>
-<li class="listitem">
- Fixed non-seekable iostream support for certain stream types, i.e.
- boost file_source with pipe input
- </li>
-<li class="listitem">
- Fixed xpath_query::return_type() for some expressions
- </li>
-<li class="listitem">
- Fixed dllexport issues with xml_named_node_iterator
- </li>
-<li class="listitem">
- Fixed find_child_by_attribute assertion for attributes with null
- name/value
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.1_05_2012___version_1_2"></a><h6>
- <a class="link" href="changes.html#manual.changes.1_05_2012___version_1_2">1.05.2012 - version
- 1.2</a>
- </h6>
-<p>
- Major release, featuring header-only mode, various interface enhancements (i.e.
- PCDATA manipulation and C++11 iteration), many other features and compatibility
- improvements.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added xml_text helper class for working with PCDATA/CDATA contents
- of an element node
- </li>
-<li class="listitem">
- Added optional header-only mode (controlled by PUGIXML_HEADER_ONLY
- define)
- </li>
-<li class="listitem">
- Added xml_node::children() and xml_node::attributes() for C++11 ranged
- for loop or BOOST_FOREACH
- </li>
-<li class="listitem">
- Added support for Latin-1 (ISO-8859-1) encoding conversion during
- loading and saving
- </li>
-<li class="listitem">
- Added custom default values for xml_attribute::as_* (they are returned if the attribute
- does not exist)
- </li>
-<li class="listitem">
- Added parse_ws_pcdata_single flag for preserving whitespace-only
- PCDATA in case it's the only child
- </li>
-<li class="listitem">
- Added format_save_file_text for xml_document::save_file to open files
- as text instead of binary (changes newlines on Windows)
- </li>
-<li class="listitem">
- Added format_no_escapes flag to disable special symbol escaping (complements
- ~parse_escapes)
- </li>
-<li class="listitem">
- Added support for loading document from streams that do not support
- seeking
- </li>
-<li class="listitem">
- Added PUGIXML_MEMORY_* constants for tweaking allocation behavior (useful for embedded
- systems)
- </li>
-<li class="listitem">
- Added PUGIXML_VERSION preprocessor define
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Compatibility improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Parser does not require setjmp support (improves compatibility with
- some embedded platforms, enables clr:pure compilation)
- </li>
-<li class="listitem">
- STL forward declarations are no longer used (fixes SunCC/RWSTL compilation,
- fixes clang compilation in C++11 mode)
- </li>
-<li class="listitem">
- Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C++/CLI compilation
- </li>
-<li class="listitem">
- Fixed several compilation warnings for various GCC versions, Intel
- C++ compiler and Clang
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed unsafe bool conversion to avoid problems on C++/CLI
- </li>
-<li class="listitem">
- Iterator dereference operator is const now (fixes Boost filter_iterator
- support)
- </li>
-<li class="listitem">
- xml_document::save_file now checks for file I/O errors during saving
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.1_11_2010___version_1_0"></a><h6>
- <a class="link" href="changes.html#manual.changes.1_11_2010___version_1_0">1.11.2010 - version
- 1.0</a>
- </h6>
-<p>
- Major release, featuring many XPath enhancements, wide character filename support,
- miscellaneous performance improvements, bug fixes and more.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- XPath:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- XPath implementation is moved to pugixml.cpp (which is the only source
- file now); use PUGIXML_NO_XPATH if you want to disable XPath to reduce
- code size
- </li>
-<li class="listitem">
- XPath is now supported without exceptions (PUGIXML_NO_EXCEPTIONS);
- the error handling mechanism depends on the presence of exception
- support
- </li>
-<li class="listitem">
- XPath is now supported without STL (PUGIXML_NO_STL)
- </li>
-<li class="listitem">
- Introduced variable support
- </li>
-<li class="listitem">
- Introduced new xpath_query::evaluate_string, which works without
- STL
- </li>
-<li class="listitem">
- Introduced new xpath_node_set constructor (from an iterator range)
- </li>
-<li class="listitem">
- Evaluation function now accept attribute context nodes
- </li>
-<li class="listitem">
- All internal allocations use custom allocation functions
- </li>
-<li class="listitem">
- Improved error reporting; now a last parsed offset is returned together
- with the parsing error
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed memory leak for loading from streams with stream exceptions
- turned on
- </li>
-<li class="listitem">
- Fixed custom deallocation function calling with null pointer in one
- case
- </li>
-<li class="listitem">
- Fixed missing attributes for iterator category functions; all functions/classes
- can now be DLL-exported
- </li>
-<li class="listitem">
- Worked around Digital Mars compiler bug, which lead to minor read
- overfetches in several functions
- </li>
-<li class="listitem">
- load_file now works with 2+ Gb files in MSVC/MinGW
- </li>
-<li class="listitem">
- XPath: fixed memory leaks for incorrect queries
- </li>
-<li class="listitem">
- XPath: fixed xpath_node() attribute constructor with empty attribute
- argument
- </li>
-<li class="listitem">
- XPath: fixed lang() function for non-ASCII arguments
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Specification changes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- CDATA nodes containing ]]&gt; are printed as several nodes; while
- this changes the internal structure, this is the only way to escape
- CDATA contents
- </li>
-<li class="listitem">
- Memory allocation errors during parsing now preserve last parsed
- offset (to give an idea about parsing progress)
- </li>
-<li class="listitem">
- If an element node has the only child, and it is of CDATA type, then
- the extra indentation is omitted (previously this behavior only held
- for PCDATA children)
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Additional functionality:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added xml_parse_result default constructor
- </li>
-<li class="listitem">
- Added xml_document::load_file and xml_document::save_file with wide
- character paths
- </li>
-<li class="listitem">
- Added as_utf8 and as_wide overloads for std::wstring/std::string
- arguments
- </li>
-<li class="listitem">
- Added DOCTYPE node type (node_doctype) and a special parse flag,
- parse_doctype, to add such nodes to the document during parsing
- </li>
-<li class="listitem">
- Added parse_full parse flag mask, which extends parse_default with
- all node type parsing flags except parse_ws_pcdata
- </li>
-<li class="listitem">
- Added xml_node::hash_value() and xml_attribute::hash_value() functions
- for use in hash-based containers
- </li>
-<li class="listitem">
- Added internal_object() and additional constructor for both xml_node
- and xml_attribute for easier marshalling (useful for language bindings)
- </li>
-<li class="listitem">
- Added xml_document::document_element() function
- </li>
-<li class="listitem">
- Added xml_node::prepend_attribute, xml_node::prepend_child and xml_node::prepend_copy
- functions
- </li>
-<li class="listitem">
- Added xml_node::append_child, xml_node::prepend_child, xml_node::insert_child_before
- and xml_node::insert_child_after overloads for element nodes (with
- name instead of type)
- </li>
-<li class="listitem">
- Added xml_document::reset() function
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Performance improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- xml_node::root() and xml_node::offset_debug() are now O(1) instead
- of O(logN)
- </li>
-<li class="listitem">
- Minor parsing optimizations
- </li>
-<li class="listitem">
- Minor memory optimization for strings in DOM tree (set_name/set_value)
- </li>
-<li class="listitem">
- Memory optimization for string memory reclaiming in DOM tree (set_name/set_value
- now reallocate the buffer if memory waste is too big)
- </li>
-<li class="listitem">
- XPath: optimized document order sorting
- </li>
-<li class="listitem">
- XPath: optimized child/attribute axis step
- </li>
-<li class="listitem">
- XPath: optimized number-to-string conversions in MSVC
- </li>
-<li class="listitem">
- XPath: optimized concat for many arguments
- </li>
-<li class="listitem">
- XPath: optimized evaluation allocation mechanism: constant and document
- strings are not heap-allocated
- </li>
-<li class="listitem">
- XPath: optimized evaluation allocation mechanism: all temporaries'
- allocations use fast stack-like allocator
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Compatibility:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Removed wildcard functions (xml_node::child_w, xml_node::attribute_w,
- etc.)
- </li>
-<li class="listitem">
- Removed xml_node::all_elements_by_name
- </li>
-<li class="listitem">
- Removed xpath_type_t enumeration; use xpath_value_type instead
- </li>
-<li class="listitem">
- Removed format_write_bom_utf8 enumeration; use format_write_bom instead
- </li>
-<li class="listitem">
- Removed xml_document::precompute_document_order, xml_attribute::document_order
- and xml_node::document_order functions; document order sort optimization
- is now automatic
- </li>
-<li class="listitem">
- Removed xml_document::parse functions and transfer_ownership struct;
- use xml_document::load_buffer_inplace and xml_document::load_buffer_inplace_own
- instead
- </li>
-<li class="listitem">
- Removed as_utf16 function; use as_wide instead
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.1_07_2010___version_0_9"></a><h6>
- <a class="link" href="changes.html#manual.changes.1_07_2010___version_0_9">1.07.2010 - version
- 0.9</a>
- </h6>
-<p>
- Major release, featuring extended and improved Unicode support, miscellaneous
- performance improvements, bug fixes and more.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Major Unicode improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Introduced encoding support (automatic/manual encoding detection
- on load, manual encoding selection on save, conversion from/to UTF8,
- UTF16 LE/BE, UTF32 LE/BE)
- </li>
-<li class="listitem">
- Introduced wchar_t mode (you can set PUGIXML_WCHAR_MODE define to
- switch pugixml internal encoding from UTF8 to wchar_t; all functions
- are switched to their Unicode variants)
- </li>
-<li class="listitem">
- Load/save functions now support wide streams
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed document corruption on failed parsing bug
- </li>
-<li class="listitem">
- XPath string &lt;-&gt; number conversion improvements (increased
- precision, fixed crash for huge numbers)
- </li>
-<li class="listitem">
- Improved DOCTYPE parsing: now parser recognizes all well-formed DOCTYPE
- declarations
- </li>
-<li class="listitem">
- Fixed xml_attribute::as_uint() for large numbers (i.e. 2^32-1)
- </li>
-<li class="listitem">
- Fixed xml_node::first_element_by_path for path components that are
- prefixes of node names, but are not exactly equal to them.
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Specification changes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- parse() API changed to load_buffer/load_buffer_inplace/load_buffer_inplace_own;
- load_buffer APIs do not require zero-terminated strings.
- </li>
-<li class="listitem">
- Renamed as_utf16 to as_wide
- </li>
-<li class="listitem">
- Changed xml_node::offset_debug return type and xml_parse_result::offset
- type to ptrdiff_t
- </li>
-<li class="listitem">
- Nodes/attributes with empty names are now printed as :anonymous
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Performance improvements:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Optimized document parsing and saving
- </li>
-<li class="listitem">
- Changed internal memory management: internal allocator is used for
- both metadata and name/value data; allocated pages are deleted if
- all allocations from them are deleted
- </li>
-<li class="listitem">
- Optimized memory consumption: sizeof(xml_node_struct) reduced from
- 40 bytes to 32 bytes on x86
- </li>
-<li class="listitem">
- Optimized debug mode parsing/saving by order of magnitude
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Miscellaneous:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- All STL includes except &lt;exception&gt; in pugixml.hpp are replaced
- with forward declarations
- </li>
-<li class="listitem">
- xml_node::remove_child and xml_node::remove_attribute now return
- the operation result
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Compatibility:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- parse() and as_utf16 are left for compatibility (these functions
- are deprecated and will be removed in version 1.0)
- </li>
-<li class="listitem">
- Wildcard functions, document_order/precompute_document_order functions,
- all_elements_by_name function and format_write_bom_utf8 flag are
- deprecated and will be removed in version 1.0
- </li>
-<li class="listitem">
- xpath_type_t enumeration was renamed to xpath_value_type; xpath_type_t
- is deprecated and will be removed in version 1.0
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.8_11_2009___version_0_5"></a><h6>
- <a class="link" href="changes.html#manual.changes.8_11_2009___version_0_5">8.11.2009 - version
- 0.5</a>
- </h6>
-<p>
- Major bugfix release. Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- XPath bugfixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed translate(), lang() and concat() functions (infinite loops/crashes)
- </li>
-<li class="listitem">
- Fixed compilation of queries with empty literal strings ("")
- </li>
-<li class="listitem">
- Fixed axis tests: they never add empty nodes/attributes to the resulting
- node set now
- </li>
-<li class="listitem">
- Fixed string-value evaluation for node-set (the result excluded some
- text descendants)
- </li>
-<li class="listitem">
- Fixed self:: axis (it behaved like ancestor-or-self::)
- </li>
-<li class="listitem">
- Fixed following:: and preceding:: axes (they included descendent
- and ancestor nodes, respectively)
- </li>
-<li class="listitem">
- Minor fix for namespace-uri() function (namespace declaration scope
- includes the parent element of namespace declaration attribute)
- </li>
-<li class="listitem">
- Some incorrect queries are no longer parsed now (i.e. foo: *)
- </li>
-<li class="listitem">
- Fixed text()/etc. node test parsing bug (i.e. foo[text()] failed
- to compile)
- </li>
-<li class="listitem">
- Fixed root step (/) - it now selects empty node set if query is evaluated
- on empty node
- </li>
-<li class="listitem">
- Fixed string to number conversion ("123 " converted to
- NaN, "123 .456" converted to 123.456 - now the results
- are 123 and NaN, respectively)
- </li>
-<li class="listitem">
- Node set copying now preserves sorted type; leads to better performance
- on some queries
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Miscellaneous bugfixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed xml_node::offset_debug for PI nodes
- </li>
-<li class="listitem">
- Added empty attribute checks to xml_node::remove_attribute
- </li>
-<li class="listitem">
- Fixed node_pi and node_declaration copying
- </li>
-<li class="listitem">
- Const-correctness fixes
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Specification changes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- xpath_node::select_nodes() and related functions now throw exception
- if expression return type is not node set (instead of assertion)
- </li>
-<li class="listitem">
- xml_node::traverse() now sets depth to -1 for both begin() and end()
- callbacks (was 0 at begin() and -1 at end())
- </li>
-<li class="listitem">
- In case of non-raw node printing a newline is output after PCDATA
- inside nodes if the PCDATA has siblings
- </li>
-<li class="listitem">
- UTF8 -&gt; wchar_t conversion now considers 5-byte UTF8-like sequences
- as invalid
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added xpath_node_set::operator[] for index-based iteration
- </li>
-<li class="listitem">
- Added xpath_query::return_type()
- </li>
-<li class="listitem">
- Added getter accessors for memory-management functions
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.17_09_2009___version_0_42"></a><h6>
- <a class="link" href="changes.html#manual.changes.17_09_2009___version_0_42">17.09.2009 - version
- 0.42</a>
- </h6>
-<p>
- Maintenance release. Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed deallocation in case of custom allocation functions or if delete[]
- / free are incompatible
- </li>
-<li class="listitem">
- XPath parser fixed for incorrect queries (i.e. incorrect XPath queries
- should now always fail to compile)
- </li>
-<li class="listitem">
- Const-correctness fixes for find_child_by_attribute
- </li>
-<li class="listitem">
- Improved compatibility (miscellaneous warning fixes, fixed cstring
- include dependency for GCC)
- </li>
-<li class="listitem">
- Fixed iterator begin/end and print function to work correctly for
- empty nodes
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added PUGIXML_API/PUGIXML_CLASS/PUGIXML_FUNCTION configuration macros
- to control class/function attributes
- </li>
-<li class="listitem">
- Added xml_attribute::set_value overloads for different types
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.8_02_2009___version_0_41"></a><h6>
- <a class="link" href="changes.html#manual.changes.8_02_2009___version_0_41">8.02.2009 - version
- 0.41</a>
- </h6>
-<p>
- Maintenance release. Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
- Fixed bug with node printing (occasionally some content was not written
- to output stream)
- </li></ol></div>
- </li></ul></div>
-<a name="manual.changes.18_01_2009___version_0_4"></a><h6>
- <a class="link" href="changes.html#manual.changes.18_01_2009___version_0_4">18.01.2009 - version
- 0.4</a>
- </h6>
-<p>
- Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Documentation fix in samples for parse() with manual lifetime control
- </li>
-<li class="listitem">
- Fixed document order sorting in XPath (it caused wrong order of nodes
- after xpath_node_set::sort and wrong results of some XPath queries)
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Node printing changes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Single quotes are no longer escaped when printing nodes
- </li>
-<li class="listitem">
- Symbols in second half of ASCII table are no longer escaped when
- printing nodes; because of this, format_utf8 flag is deleted as it's
- no longer needed and format_write_bom is renamed to format_write_bom_utf8.
- </li>
-<li class="listitem">
- Reworked node printing - now it works via xml_writer interface; implementations
- for FILE* and std::ostream are available. As a side-effect, xml_document::save_file
- now works without STL.
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added unsigned integer support for attributes (xml_attribute::as_uint,
- xml_attribute::operator=)
- </li>
-<li class="listitem">
- Now document declaration (&lt;?xml ...?&gt;) is parsed as node with
- type node_declaration when parse_declaration flag is specified (access
- to encoding/version is performed as if they were attributes, i.e.
- doc.child("xml").attribute("version").as_float());
- corresponding flags for node printing were also added
- </li>
-<li class="listitem">
- Added support for custom memory management (see set_memory_management_functions
- for details)
- </li>
-<li class="listitem">
- Implemented node/attribute copying (see xml_node::insert_copy_* and
- xml_node::append_copy for details)
- </li>
-<li class="listitem">
- Added find_child_by_attribute and find_child_by_attribute_w to simplify
- parsing code in some cases (i.e. COLLADA files)
- </li>
-<li class="listitem">
- Added file offset information querying for debugging purposes (now
- you're able to determine exact location of any xml_node in parsed
- file, see xml_node::offset_debug for details)
- </li>
-<li class="listitem">
- Improved error handling for parsing - now load(), load_file() and
- parse() return xml_parse_result, which contains error code and last
- parsed offset; this does not break old interface as xml_parse_result
- can be implicitly casted to bool.
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.31_10_2007___version_0_34"></a><h6>
- <a class="link" href="changes.html#manual.changes.31_10_2007___version_0_34">31.10.2007 - version
- 0.34</a>
- </h6>
-<p>
- Maintenance release. Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed bug with loading from text-mode iostreams
- </li>
-<li class="listitem">
- Fixed leak when transfer_ownership is true and parsing is failing
- </li>
-<li class="listitem">
- Fixed bug in saving (\r and \n are now escaped in attribute values)
- </li>
-<li class="listitem">
- Renamed free() to destroy() - some macro conflicts were reported
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Improved compatibility (supported Digital Mars C++, MSVC 6, CodeWarrior
- 8, PGI C++, Comeau, supported PS3 and XBox360)
- </li>
-<li class="listitem">
- PUGIXML_NO_EXCEPTION flag for platforms without exception handling
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.21_02_2007___version_0_3"></a><h6>
- <a class="link" href="changes.html#manual.changes.21_02_2007___version_0_3">21.02.2007 - version
- 0.3</a>
- </h6>
-<p>
- Refactored, reworked and improved version. Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Interface:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Added XPath
- </li>
-<li class="listitem">
- Added tree modification functions
- </li>
-<li class="listitem">
- Added no STL compilation mode
- </li>
-<li class="listitem">
- Added saving document to file
- </li>
-<li class="listitem">
- Refactored parsing flags
- </li>
-<li class="listitem">
- Removed xml_parser class in favor of xml_document
- </li>
-<li class="listitem">
- Added transfer ownership parsing mode
- </li>
-<li class="listitem">
- Modified the way xml_tree_walker works
- </li>
-<li class="listitem">
- Iterators are now non-constant
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- Implementation:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Support of several compilers and platforms
- </li>
-<li class="listitem">
- Refactored and sped up parsing core
- </li>
-<li class="listitem">
- Improved standard compliancy
- </li>
-<li class="listitem">
- Added XPath implementation
- </li>
-<li class="listitem">
- Fixed several bugs
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.6_11_2006___version_0_2"></a><h6>
- <a class="link" href="changes.html#manual.changes.6_11_2006___version_0_2">6.11.2006 - version
- 0.2</a>
- </h6>
-<p>
- First public release. Changes:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Bug fixes:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Fixed child_value() (for empty nodes)
- </li>
-<li class="listitem">
- Fixed xml_parser_impl warning at W4
- </li>
-</ol></div>
- </li>
-<li class="listitem">
- New features:
- <div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Introduced child_value(name) and child_value_w(name)
- </li>
-<li class="listitem">
- parse_eol_pcdata and parse_eol_attribute flags + parse_minimal optimizations
- </li>
-<li class="listitem">
- Optimizations of strconv_t
- </li>
-</ol></div>
- </li>
-</ul></div>
-<a name="manual.changes.15_07_2006___version_0_1"></a><h6>
- <a class="link" href="changes.html#manual.changes.15_07_2006___version_0_1">15.07.2006 - version
- 0.1</a>
- </h6>
-<p>
- First private release for testing purposes
- </p>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="xpath.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="apiref.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/dom.html b/docs/manual/dom.html
deleted file mode 100644
index 3d7cd29..0000000
--- a/docs/manual/dom.html
+++ /dev/null
@@ -1,732 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Document object model</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="install.html" title="Installation">
-<link rel="next" href="loading.html" title="Loading document">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <b>Object model</b> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="install.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="loading.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.dom"></a><a class="link" href="dom.html" title="Document object model"> Document object model</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="dom.html#manual.dom.tree"> Tree structure</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.cpp"> C++ interface</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.unicode"> Unicode interface</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.thread"> Thread-safety guarantees</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.exception"> Exception guarantees</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.memory"> Memory management</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="dom.html#manual.dom.memory.custom"> Custom memory allocation/deallocation
- functions</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.memory.tuning"> Memory consumption tuning</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.memory.internals"> Document memory management
- internals</a></span></dt>
-</dl></dd>
-</dl></div>
-<p>
- pugixml stores XML data in DOM-like way: the entire XML document (both document
- structure and element data) is stored in memory as a tree. The tree can be
- loaded from a character stream (file, string, C++ I/O stream), then traversed
- with the special API or XPath expressions. The whole tree is mutable: both
- node structure and node/attribute data can be changed at any time. Finally,
- the result of document transformations can be saved to a character stream (file,
- C++ I/O stream or custom transport).
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.dom.tree"></a><a class="link" href="dom.html#manual.dom.tree" title="Tree structure"> Tree structure</a>
-</h3></div></div></div>
-<p>
- The XML document is represented with a tree data structure. The root of the
- tree is the document itself, which corresponds to C++ type <a class="link" href="dom.html#xml_document">xml_document</a>.
- Document has one or more child nodes, which correspond to C++ type <a class="link" href="dom.html#xml_node">xml_node</a>. Nodes have different types; depending
- on a type, a node can have a collection of child nodes, a collection of attributes,
- which correspond to C++ type <a class="link" href="dom.html#xml_attribute">xml_attribute</a>,
- and some additional data (i.e. name).
- </p>
-<a name="xml_node_type"></a><p>
- The tree nodes can be of one of the following types (which together form
- the enumeration <code class="computeroutput"><span class="identifier">xml_node_type</span></code>):
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Document node (<a name="node_document"></a><code class="literal">node_document</code>) - this
- is the root of the tree, which consists of several child nodes. This
- node corresponds to <a class="link" href="dom.html#xml_document">xml_document</a>
- class; note that <a class="link" href="dom.html#xml_document">xml_document</a> is
- a sub-class of <a class="link" href="dom.html#xml_node">xml_node</a>, so the entire
- node interface is also available. However, document node is special in
- several ways, which are covered below. There can be only one document
- node in the tree; document node does not have any XML representation.
- <br><br>
-
- </li>
-<li class="listitem">
- Element/tag node (<a name="node_element"></a><code class="literal">node_element</code>) - this
- is the most common type of node, which represents XML elements. Element
- nodes have a name, a collection of attributes and a collection of child
- nodes (both of which may be empty). The attribute is a simple name/value
- pair. The example XML representation of element nodes is as follows:
- </li>
-</ul></div>
-<pre class="programlisting"><span class="special">&lt;</span><span class="identifier">node</span> <span class="identifier">attr</span><span class="special">=</span><span class="string">"value"</span><span class="special">&gt;&lt;</span><span class="identifier">child</span><span class="special">/&gt;&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- There are two element nodes here: one has name <code class="computeroutput"><span class="string">"node"</span></code>,
- single attribute <code class="computeroutput"><span class="string">"attr"</span></code>
- and single child <code class="computeroutput"><span class="string">"child"</span></code>,
- another has name <code class="computeroutput"><span class="string">"child"</span></code>
- and does not have any attributes or child nodes.
- </p></blockquote></div>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Plain character data nodes (<a name="node_pcdata"></a><code class="literal">node_pcdata</code>)
- represent plain text in XML. PCDATA nodes have a value, but do not have
- a name or children/attributes. Note that <span class="bold"><strong>plain
- character data is not a part of the element node but instead has its
- own node</strong></span>; an element node can have several child PCDATA nodes.
- The example XML representation of text nodes is as follows:
- </li></ul></div>
-<pre class="programlisting"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span> <span class="identifier">text1</span> <span class="special">&lt;</span><span class="identifier">child</span><span class="special">/&gt;</span> <span class="identifier">text2</span> <span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- Here <code class="computeroutput"><span class="string">"node"</span></code> element
- has three children, two of which are PCDATA nodes with values <code class="computeroutput"><span class="string">" text1 "</span></code> and <code class="computeroutput"><span class="string">"
- text2 "</span></code>.
- </p></blockquote></div>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Character data nodes (<a name="node_cdata"></a><code class="literal">node_cdata</code>) represent
- text in XML that is quoted in a special way. CDATA nodes do not differ
- from PCDATA nodes except in XML representation - the above text example
- looks like this with CDATA:
- </li></ul></div>
-<pre class="programlisting"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span> <span class="special">&lt;![</span><span class="identifier">CDATA</span><span class="special">[[</span><span class="identifier">text1</span><span class="special">]]&gt;</span> <span class="special">&lt;</span><span class="identifier">child</span><span class="special">/&gt;</span> <span class="special">&lt;![</span><span class="identifier">CDATA</span><span class="special">[[</span><span class="identifier">text2</span><span class="special">]]&gt;</span> <span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- CDATA nodes make it easy to include non-escaped &lt;, &amp; and &gt; characters
- in plain text. CDATA value can not contain the character sequence ]]&gt;,
- since it is used to determine the end of node contents.
- </p></blockquote></div>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Comment nodes (<a name="node_comment"></a><code class="literal">node_comment</code>) represent
- comments in XML. Comment nodes have a value, but do not have a name or
- children/attributes. The example XML representation of a comment node
- is as follows:
- </li></ul></div>
-<pre class="programlisting"><span class="special">&lt;!--</span> <span class="identifier">comment</span> <span class="identifier">text</span> <span class="special">--&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- Here the comment node has value <code class="computeroutput"><span class="string">"comment
- text"</span></code>. By default comment nodes are treated as non-essential
- part of XML markup and are not loaded during XML parsing. You can override
- this behavior with <a class="link" href="loading.html#parse_comments">parse_comments</a>
- flag.
- </p></blockquote></div>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Processing instruction node (<a name="node_pi"></a><code class="literal">node_pi</code>) represent
- processing instructions (PI) in XML. PI nodes have a name and an optional
- value, but do not have children/attributes. The example XML representation
- of a PI node is as follows:
- </li></ul></div>
-<pre class="programlisting"><span class="special">&lt;?</span><span class="identifier">name</span> <span class="identifier">value</span><span class="special">?&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- Here the name (also called PI target) is <code class="computeroutput"><span class="string">"name"</span></code>,
- and the value is <code class="computeroutput"><span class="string">"value"</span></code>.
- By default PI nodes are treated as non-essential part of XML markup and
- are not loaded during XML parsing. You can override this behavior with
- <a class="link" href="loading.html#parse_pi">parse_pi</a> flag.
- </p></blockquote></div>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Declaration node (<a name="node_declaration"></a><code class="literal">node_declaration</code>)
- represents document declarations in XML. Declaration nodes have a name
- (<code class="computeroutput"><span class="string">"xml"</span></code>) and an
- optional collection of attributes, but do not have value or children.
- There can be only one declaration node in a document; moreover, it should
- be the topmost node (its parent should be the document). The example
- XML representation of a declaration node is as follows:
- </li></ul></div>
-<pre class="programlisting"><span class="special">&lt;?</span><span class="identifier">xml</span> <span class="identifier">version</span><span class="special">=</span><span class="string">"1.0"</span><span class="special">?&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- Here the node has name <code class="computeroutput"><span class="string">"xml"</span></code>
- and a single attribute with name <code class="computeroutput"><span class="string">"version"</span></code>
- and value <code class="computeroutput"><span class="string">"1.0"</span></code>.
- By default declaration nodes are treated as non-essential part of XML markup
- and are not loaded during XML parsing. You can override this behavior with
- <a class="link" href="loading.html#parse_declaration">parse_declaration</a> flag. Also,
- by default a dummy declaration is output when XML document is saved unless
- there is already a declaration in the document; you can disable this with
- <a class="link" href="saving.html#format_no_declaration">format_no_declaration</a> flag.
- </p></blockquote></div>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Document type declaration node (<a name="node_doctype"></a><code class="literal">node_doctype</code>)
- represents document type declarations in XML. Document type declaration
- nodes have a value, which corresponds to the entire document type contents;
- no additional nodes are created for inner elements like <code class="computeroutput"><span class="special">&lt;!</span><span class="identifier">ENTITY</span><span class="special">&gt;</span></code>. There can be only one document type
- declaration node in a document; moreover, it should be the topmost node
- (its parent should be the document). The example XML representation of
- a document type declaration node is as follows:
- </li></ul></div>
-<pre class="programlisting"><span class="special">&lt;!</span><span class="identifier">DOCTYPE</span> <span class="identifier">greeting</span> <span class="special">[</span> <span class="special">&lt;!</span><span class="identifier">ELEMENT</span> <span class="identifier">greeting</span> <span class="special">(</span><span class="preprocessor">#PCDATA</span><span class="special">)&gt;</span> <span class="special">]&gt;</span>
-</pre>
-<div class="blockquote"><blockquote class="blockquote"><p>
- Here the node has value <code class="computeroutput"><span class="string">"greeting [ &lt;!ELEMENT
- greeting (#PCDATA)&gt; ]"</span></code>. By default document type
- declaration nodes are treated as non-essential part of XML markup and are
- not loaded during XML parsing. You can override this behavior with <a class="link" href="loading.html#parse_doctype">parse_doctype</a> flag.
- </p></blockquote></div>
-<p>
- Finally, here is a complete example of XML document and the corresponding
- tree representation (<a href="../samples/tree.xml" target="_top">samples/tree.xml</a>):
- </p>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<tbody><tr>
-<td>
- <p>
-
-</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">&lt;?</span><span class="identifier">xml</span> <span class="identifier">version</span><span class="special">=</span><span class="string">"1.0"</span><span class="special">?&gt;</span>
-<span class="special">&lt;</span><span class="identifier">mesh</span> <span class="identifier">name</span><span class="special">=</span><span class="string">"mesh_root"</span><span class="special">&gt;</span>
- <span class="special">&lt;!--</span> <span class="identifier">here</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">mesh</span> <span class="identifier">node</span> <span class="special">--&gt;</span>
- <span class="identifier">some</span> <span class="identifier">text</span>
- <span class="special">&lt;![</span><span class="identifier">CDATA</span><span class="special">[</span><span class="identifier">someothertext</span><span class="special">]]&gt;</span>
- <span class="identifier">some</span> <span class="identifier">more</span> <span class="identifier">text</span>
- <span class="special">&lt;</span><span class="identifier">node</span> <span class="identifier">attr1</span><span class="special">=</span><span class="string">"value1"</span> <span class="identifier">attr2</span><span class="special">=</span><span class="string">"value2"</span> <span class="special">/&gt;</span>
- <span class="special">&lt;</span><span class="identifier">node</span> <span class="identifier">attr1</span><span class="special">=</span><span class="string">"value2"</span><span class="special">&gt;</span>
- <span class="special">&lt;</span><span class="identifier">innernode</span><span class="special">/&gt;</span>
- <span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span>
-<span class="special">&lt;/</span><span class="identifier">mesh</span><span class="special">&gt;</span>
-<span class="special">&lt;?</span><span class="identifier">include</span> <span class="identifier">somedata</span><span class="special">?&gt;</span>
-</pre>
-<p>
- </p>
- </td>
-<td>
- <p>
- <a href="../images/dom_tree.png" target="_top"><span class="inlinemediaobject"><img src="../images/dom_tree_thumb.png" alt="dom_tree_thumb"></span></a>
- </p>
- </td>
-</tr></tbody>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.dom.cpp"></a><a class="link" href="dom.html#manual.dom.cpp" title="C++ interface"> C++ interface</a>
-</h3></div></div></div>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- All pugixml classes and functions are located in the <code class="computeroutput"><span class="identifier">pugi</span></code>
- namespace; you have to either use explicit name qualification (i.e. <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span></code>), or to gain access to relevant
- symbols via <code class="computeroutput"><span class="keyword">using</span></code> directive
- (i.e. <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">;</span></code> or <code class="computeroutput"><span class="keyword">using</span>
- <span class="keyword">namespace</span> <span class="identifier">pugi</span><span class="special">;</span></code>). The namespace will be omitted from all
- declarations in this documentation hereafter; all code examples will use
- fully qualified names.
- </p></td></tr>
-</table></div>
-<p>
- Despite the fact that there are several node types, there are only three
- C++ classes representing the tree (<code class="computeroutput"><span class="identifier">xml_document</span></code>,
- <code class="computeroutput"><span class="identifier">xml_node</span></code>, <code class="computeroutput"><span class="identifier">xml_attribute</span></code>);
- some operations on <code class="computeroutput"><span class="identifier">xml_node</span></code>
- are only valid for certain node types. The classes are described below.
- </p>
-<a name="xml_document"></a><a name="xml_document::document_element"></a><p>
- <code class="computeroutput"><span class="identifier">xml_document</span></code> is the owner
- of the entire document structure; it is a non-copyable class. The interface
- of <code class="computeroutput"><span class="identifier">xml_document</span></code> consists
- of loading functions (see <a class="xref" href="loading.html" title="Loading document"> Loading document</a>), saving functions (see <a class="xref" href="saving.html" title="Saving document"> Saving document</a>)
- and the entire interface of <code class="computeroutput"><span class="identifier">xml_node</span></code>,
- which allows for document inspection and/or modification. Note that while
- <code class="computeroutput"><span class="identifier">xml_document</span></code> is a sub-class
- of <code class="computeroutput"><span class="identifier">xml_node</span></code>, <code class="computeroutput"><span class="identifier">xml_node</span></code> is not a polymorphic type; the
- inheritance is present only to simplify usage. Alternatively you can use
- the <code class="computeroutput"><span class="identifier">document_element</span></code> function
- to get the element node that's the immediate child of the document.
- </p>
-<a name="xml_document::ctor"></a><a name="xml_document::dtor"></a><a name="xml_document::reset"></a><p>
- Default constructor of <code class="computeroutput"><span class="identifier">xml_document</span></code>
- initializes the document to the tree with only a root node (document node).
- You can then populate it with data using either tree modification functions
- or loading functions; all loading functions destroy the previous tree with
- all occupied memory, which puts existing node/attribute handles for this
- document to invalid state. If you want to destroy the previous tree, you
- can use the <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">reset</span></code>
- function; it destroys the tree and replaces it with either an empty one or
- a copy of the specified document. Destructor of <code class="computeroutput"><span class="identifier">xml_document</span></code>
- also destroys the tree, thus the lifetime of the document object should exceed
- the lifetimes of any node/attribute handles that point to the tree.
- </p>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- While technically node/attribute handles can be alive when the tree they're
- referring to is destroyed, calling any member function for these handles
- results in undefined behavior. Thus it is recommended to make sure that
- the document is destroyed only after all references to its nodes/attributes
- are destroyed.
- </p></td></tr>
-</table></div>
-<a name="xml_node"></a><a name="xml_node::type"></a><p>
- <code class="computeroutput"><span class="identifier">xml_node</span></code> is the handle to
- document node; it can point to any node in the document, including the document
- node itself. There is a common interface for nodes of all types; the actual
- <a class="link" href="dom.html#xml_node_type">node type</a> can be queried via the <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span></code>
- method. Note that <code class="computeroutput"><span class="identifier">xml_node</span></code>
- is only a handle to the actual node, not the node itself - you can have several
- <code class="computeroutput"><span class="identifier">xml_node</span></code> handles pointing
- to the same underlying object. Destroying <code class="computeroutput"><span class="identifier">xml_node</span></code>
- handle does not destroy the node and does not remove it from the tree. The
- size of <code class="computeroutput"><span class="identifier">xml_node</span></code> is equal
- to that of a pointer, so it is nothing more than a lightweight wrapper around
- a pointer; you can safely pass or return <code class="computeroutput"><span class="identifier">xml_node</span></code>
- objects by value without additional overhead.
- </p>
-<a name="node_null"></a><p>
- There is a special value of <code class="computeroutput"><span class="identifier">xml_node</span></code>
- type, known as null node or empty node (such nodes have type <code class="computeroutput"><span class="identifier">node_null</span></code>). It does not correspond to any
- node in any document, and thus resembles null pointer. However, all operations
- are defined on empty nodes; generally the operations don't do anything and
- return empty nodes/attributes or empty strings as their result (see documentation
- for specific functions for more detailed information). This is useful for
- chaining calls; i.e. you can get the grandparent of a node like so: <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">parent</span><span class="special">().</span><span class="identifier">parent</span><span class="special">()</span></code>; if a node is a null node or it does not
- have a parent, the first <code class="computeroutput"><span class="identifier">parent</span><span class="special">()</span></code> call returns null node; the second <code class="computeroutput"><span class="identifier">parent</span><span class="special">()</span></code>
- call then also returns null node, which makes error handling easier.
- </p>
-<a name="xml_attribute"></a><p>
- <code class="computeroutput"><span class="identifier">xml_attribute</span></code> is the handle
- to an XML attribute; it has the same semantics as <code class="computeroutput"><span class="identifier">xml_node</span></code>,
- i.e. there can be several <code class="computeroutput"><span class="identifier">xml_attribute</span></code>
- handles pointing to the same underlying object and there is a special null
- attribute value, which propagates to function results.
- </p>
-<a name="xml_attribute::ctor"></a><a name="xml_node::ctor"></a><p>
- Both <code class="computeroutput"><span class="identifier">xml_node</span></code> and <code class="computeroutput"><span class="identifier">xml_attribute</span></code> have the default constructor
- which initializes them to null objects.
- </p>
-<a name="xml_attribute::comparison"></a><a name="xml_node::comparison"></a><p>
- <code class="computeroutput"><span class="identifier">xml_node</span></code> and <code class="computeroutput"><span class="identifier">xml_attribute</span></code> try to behave like pointers,
- that is, they can be compared with other objects of the same type, making
- it possible to use them as keys in associative containers. All handles to
- the same underlying object are equal, and any two handles to different underlying
- objects are not equal. Null handles only compare as equal to themselves.
- The result of relational comparison can not be reliably determined from the
- order of nodes in file or in any other way. Do not use relational comparison
- operators except for search optimization (i.e. associative container keys).
- </p>
-<a name="xml_attribute::hash_value"></a><a name="xml_node::hash_value"></a><p>
- If you want to use <code class="computeroutput"><span class="identifier">xml_node</span></code>
- or <code class="computeroutput"><span class="identifier">xml_attribute</span></code> objects
- as keys in hash-based associative containers, you can use the <code class="computeroutput"><span class="identifier">hash_value</span></code> member functions. They return
- the hash values that are guaranteed to be the same for all handles to the
- same underlying object. The hash value for null handles is 0.
- </p>
-<a name="xml_attribute::unspecified_bool_type"></a><a name="xml_node::unspecified_bool_type"></a><a name="xml_attribute::empty"></a><a name="xml_node::empty"></a><p>
- Finally handles can be implicitly cast to boolean-like objects, so that you
- can test if the node/attribute is empty with the following code: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span></code> or <code class="computeroutput"><span class="keyword">if</span>
- <span class="special">(!</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>.
- Alternatively you can check if a given <code class="computeroutput"><span class="identifier">xml_node</span></code>/<code class="computeroutput"><span class="identifier">xml_attribute</span></code> handle is null by calling
- the following methods:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- Nodes and attributes do not exist without a document tree, so you can't create
- them without adding them to some document. Once underlying node/attribute
- objects are destroyed, the handles to those objects become invalid. While
- this means that destruction of the entire tree invalidates all node/attribute
- handles, it also means that destroying a subtree (by calling <a class="link" href="modify.html#xml_node::remove_child">xml_node::remove_child</a>)
- or removing an attribute invalidates the corresponding handles. There is
- no way to check handle validity; you have to ensure correctness through external
- mechanisms.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.dom.unicode"></a><a class="link" href="dom.html#manual.dom.unicode" title="Unicode interface"> Unicode interface</a>
-</h3></div></div></div>
-<p>
- There are two choices of interface and internal representation when configuring
- pugixml: you can either choose the UTF-8 (also called char) interface or
- UTF-16/32 (also called wchar_t) one. The choice is controlled via <a class="link" href="install.html#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a>
- define; you can set it via <code class="filename">pugiconfig.hpp</code> or via preprocessor options, as
- discussed in <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration
- options</a>. If this define is set, the wchar_t
- interface is used; otherwise (by default) the char interface is used. The
- exact wide character encoding is assumed to be either UTF-16 or UTF-32 and
- is determined based on the size of <code class="computeroutput"><span class="keyword">wchar_t</span></code>
- type.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- If the size of <code class="computeroutput"><span class="keyword">wchar_t</span></code> is
- 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some
- characters are represented as two code points.
- </p></td></tr>
-</table></div>
-<p>
- All tree functions that work with strings work with either C-style null terminated
- strings or STL strings of the selected character type. For example, node
- name accessors look like this in char mode:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">value</span><span class="special">);</span>
-</pre>
-<p>
- and like this in wchar_t mode:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">value</span><span class="special">);</span>
-</pre>
-<a name="char_t"></a><a name="string_t"></a><p>
- There is a special type, <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">char_t</span></code>,
- that is defined as the character type and depends on the library configuration;
- it will be also used in the documentation hereafter. There is also a type
- <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">string_t</span></code>, which is defined as the STL string
- of the character type; it corresponds to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>
- in char mode and to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span></code> in wchar_t mode.
- </p>
-<p>
- In addition to the interface, the internal implementation changes to store
- XML data as <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">char_t</span></code>; this means that these two modes
- have different memory usage characteristics. The conversion to <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">char_t</span></code> upon document loading and from
- <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">char_t</span></code> upon document saving happen automatically,
- which also carries minor performance penalty. The general advice however
- is to select the character mode based on usage scenario, i.e. if UTF-8 is
- inconvenient to process and most of your XML data is non-ASCII, wchar_t mode
- is probably a better choice.
- </p>
-<a name="as_utf8"></a><a name="as_wide"></a><p>
- There are cases when you'll have to convert string data between UTF-8 and
- wchar_t encodings; the following helper functions are provided for such purposes:
- </p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">as_utf8</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span> <span class="identifier">as_wide</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">str</span><span class="special">);</span>
-</pre>
-<p>
- Both functions accept a null-terminated string as an argument <code class="computeroutput"><span class="identifier">str</span></code>, and return the converted string.
- <code class="computeroutput"><span class="identifier">as_utf8</span></code> performs conversion
- from UTF-16/32 to UTF-8; <code class="computeroutput"><span class="identifier">as_wide</span></code>
- performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently
- discarded upon conversion. <code class="computeroutput"><span class="identifier">str</span></code>
- has to be a valid string; passing null pointer results in undefined behavior.
- There are also two overloads with the same semantics which accept a string
- as an argument:
- </p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">as_utf8</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span><span class="special">&amp;</span> <span class="identifier">str</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span> <span class="identifier">as_wide</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">str</span><span class="special">);</span>
-</pre>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top">
-<p>
- Most examples in this documentation assume char interface and therefore
- will not compile with <a class="link" href="install.html#PUGIXML_WCHAR_MODE">PUGIXML_WCHAR_MODE</a>.
- This is done to simplify the documentation; usually the only changes you'll
- have to make is to pass <code class="computeroutput"><span class="keyword">wchar_t</span></code>
- string literals, i.e. instead of
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span>
- <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"bookstore"</span><span class="special">).</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="string">"book"</span><span class="special">,</span> <span class="string">"id"</span><span class="special">,</span> <span class="string">"12345"</span><span class="special">);</span></code>
- </p>
-<p>
- you'll have to do
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span>
- <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="identifier">L</span><span class="string">"bookstore"</span><span class="special">).</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="identifier">L</span><span class="string">"book"</span><span class="special">,</span> <span class="identifier">L</span><span class="string">"id"</span><span class="special">,</span> <span class="identifier">L</span><span class="string">"12345"</span><span class="special">);</span></code>
- </p>
-</td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.dom.thread"></a><a class="link" href="dom.html#manual.dom.thread" title="Thread-safety guarantees"> Thread-safety guarantees</a>
-</h3></div></div></div>
-<p>
- Almost all functions in pugixml have the following thread-safety guarantees:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- it is safe to call free (non-member) functions from multiple threads
- </li>
-<li class="listitem">
- it is safe to perform concurrent read-only accesses to the same tree
- (all constant member functions do not modify the tree)
- </li>
-<li class="listitem">
- it is safe to perform concurrent read/write accesses, if there is only
- one read or write access to the single tree at a time
- </li>
-</ul></div>
-<p>
- Concurrent modification and traversing of a single tree requires synchronization,
- for example via reader-writer lock. Modification includes altering document
- structure and altering individual node/attribute data, i.e. changing names/values.
- </p>
-<p>
- The only exception is <a class="link" href="dom.html#set_memory_management_functions">set_memory_management_functions</a>;
- it modifies global variables and as such is not thread-safe. Its usage policy
- has more restrictions, see <a class="xref" href="dom.html#manual.dom.memory.custom" title="Custom memory allocation/deallocation functions"> Custom memory allocation/deallocation
- functions</a>.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.dom.exception"></a><a class="link" href="dom.html#manual.dom.exception" title="Exception guarantees"> Exception guarantees</a>
-</h3></div></div></div>
-<p>
- With the exception of XPath, pugixml itself does not throw any exceptions.
- Additionally, most pugixml functions have a no-throw exception guarantee.
- </p>
-<p>
- This is not applicable to functions that operate on STL strings or IOstreams;
- such functions have either strong guarantee (functions that operate on strings)
- or basic guarantee (functions that operate on streams). Also functions that
- call user-defined callbacks (i.e. <a class="link" href="access.html#xml_node::traverse">xml_node::traverse</a>
- or <a class="link" href="access.html#xml_node::find_node">xml_node::find_node</a>) do not
- provide any exception guarantees beyond the ones provided by the callback.
- </p>
-<p>
- If exception handling is not disabled with <a class="link" href="install.html#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a>
- define, XPath functions may throw <a class="link" href="xpath.html#xpath_exception">xpath_exception</a>
- on parsing errors; also, XPath functions may throw <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code>
- in low memory conditions. Still, XPath functions provide strong exception
- guarantee.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.dom.memory"></a><a class="link" href="dom.html#manual.dom.memory" title="Memory management"> Memory management</a>
-</h3></div></div></div>
-<p>
- pugixml requests the memory needed for document storage in big chunks, and
- allocates document data inside those chunks. This section discusses replacing
- functions used for chunk allocation and internal memory management implementation.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.dom.memory.custom"></a><a class="link" href="dom.html#manual.dom.memory.custom" title="Custom memory allocation/deallocation functions"> Custom memory allocation/deallocation
- functions</a>
-</h4></div></div></div>
-<a name="allocation_function"></a><a name="deallocation_function"></a><p>
- All memory for tree structure, tree data and XPath objects is allocated
- via globally specified functions, which default to malloc/free. You can
- set your own allocation functions with set_memory_management function.
- The function interfaces are the same as that of malloc/free:
- </p>
-<pre class="programlisting"><span class="keyword">typedef</span> <span class="keyword">void</span><span class="special">*</span> <span class="special">(*</span><span class="identifier">allocation_function</span><span class="special">)(</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">);</span>
-<span class="keyword">typedef</span> <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">deallocation_function</span><span class="special">)(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">ptr</span><span class="special">);</span>
-</pre>
-<a name="set_memory_management_functions"></a><a name="get_memory_allocation_function"></a><a name="get_memory_deallocation_function"></a><p>
- You can use the following accessor functions to change or get current memory
- management functions:
- </p>
-<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">set_memory_management_functions</span><span class="special">(</span><span class="identifier">allocation_function</span> <span class="identifier">allocate</span><span class="special">,</span> <span class="identifier">deallocation_function</span> <span class="identifier">deallocate</span><span class="special">);</span>
-<span class="identifier">allocation_function</span> <span class="identifier">get_memory_allocation_function</span><span class="special">();</span>
-<span class="identifier">deallocation_function</span> <span class="identifier">get_memory_deallocation_function</span><span class="special">();</span>
-</pre>
-<p>
- Allocation function is called with the size (in bytes) as an argument and
- should return a pointer to a memory block with alignment that is suitable
- for storage of primitive types (usually a maximum of <code class="computeroutput"><span class="keyword">void</span><span class="special">*</span></code> and <code class="computeroutput"><span class="keyword">double</span></code>
- types alignment is sufficient) and size that is greater than or equal to
- the requested one. If the allocation fails, the function has to return
- null pointer (throwing an exception from allocation function results in
- undefined behavior).
- </p>
-<p>
- Deallocation function is called with the pointer that was returned by some
- call to allocation function; it is never called with a null pointer. If
- memory management functions are not thread-safe, library thread safety
- is not guaranteed.
- </p>
-<p>
- This is a simple example of custom memory management (<a href="../samples/custom_memory_management.cpp" target="_top">samples/custom_memory_management.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">void</span><span class="special">*</span> <span class="identifier">custom_allocate</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="keyword">return</span> <span class="keyword">new</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">nothrow</span><span class="special">)</span> <span class="keyword">char</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span>
-<span class="special">}</span>
-
-<span class="keyword">void</span> <span class="identifier">custom_deallocate</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">ptr</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="keyword">delete</span><span class="special">[]</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">*&gt;(</span><span class="identifier">ptr</span><span class="special">);</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">set_memory_management_functions</span><span class="special">(</span><span class="identifier">custom_allocate</span><span class="special">,</span> <span class="identifier">custom_deallocate</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
- When setting new memory management functions, care must be taken to make
- sure that there are no live pugixml objects. Otherwise when the objects
- are destroyed, the new deallocation function will be called with the memory
- obtained by the old allocation function, resulting in undefined behavior.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.dom.memory.tuning"></a><a class="link" href="dom.html#manual.dom.memory.tuning" title="Memory consumption tuning"> Memory consumption tuning</a>
-</h4></div></div></div>
-<p>
- There are several important buffering optimizations in pugixml that rely
- on predefined constants. These constants have default values that were
- tuned for common usage patterns; for some applications, changing these
- constants might improve memory consumption or increase performance. Changing
- these constants is not recommended unless their default values result in
- visible problems.
- </p>
-<p>
- These constants can be tuned via configuration defines, as discussed in
- <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration
- options</a>; it is recommended to set them in <code class="filename">pugiconfig.hpp</code>.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">PUGIXML_MEMORY_PAGE_SIZE</span></code>
- controls the page size for document memory allocation. Memory for node/attribute
- objects is allocated in pages of the specified size. The default size
- is 32 Kb; for some applications the size is too large (i.e. embedded
- systems with little heap space or applications that keep lots of XML
- documents in memory). A minimum size of 1 Kb is recommended. <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">PUGIXML_MEMORY_OUTPUT_STACK</span></code>
- controls the cumulative stack space required to output the node. Any
- output operation (i.e. saving a subtree to file) uses an internal buffering
- scheme for performance reasons. The default size is 10 Kb; if you're
- using node output from threads with little stack space, decreasing
- this value can prevent stack overflows. A minimum size of 1 Kb is recommended.
- <br><br>
-
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">PUGIXML_MEMORY_XPATH_PAGE_SIZE</span></code>
- controls the page size for XPath memory allocation. Memory for XPath
- query objects as well as internal memory for XPath evaluation is allocated
- in pages of the specified size. The default size is 4 Kb; if you have
- a lot of resident XPath query objects, you might need to decrease the
- size to improve memory consumption. A minimum size of 256 bytes is
- recommended.
- </li>
-</ul></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.dom.memory.internals"></a><a class="link" href="dom.html#manual.dom.memory.internals" title="Document memory management internals"> Document memory management
- internals</a>
-</h4></div></div></div>
-<p>
- Constructing a document object using the default constructor does not result
- in any allocations; document node is stored inside the <a class="link" href="dom.html#xml_document">xml_document</a>
- object.
- </p>
-<p>
- When the document is loaded from file/buffer, unless an inplace loading
- function is used (see <a class="xref" href="loading.html#manual.loading.memory" title="Loading document from memory"> Loading document from memory</a>), a complete copy of character
- stream is made; all names/values of nodes and attributes are allocated
- in this buffer. This buffer is allocated via a single large allocation
- and is only freed when document memory is reclaimed (i.e. if the <a class="link" href="dom.html#xml_document">xml_document</a> object is destroyed or if another
- document is loaded in the same object). Also when loading from file or
- stream, an additional large allocation may be performed if encoding conversion
- is required; a temporary buffer is allocated, and it is freed before load
- function returns.
- </p>
-<p>
- All additional memory, such as memory for document structure (node/attribute
- objects) and memory for node/attribute names/values is allocated in pages
- on the order of 32 kilobytes; actual objects are allocated inside the pages
- using a memory management scheme optimized for fast allocation/deallocation
- of many small objects. Because of the scheme specifics, the pages are only
- destroyed if all objects inside them are destroyed; also, generally destroying
- an object does not mean that subsequent object creation will reuse the
- same memory. This means that it is possible to devise a usage scheme which
- will lead to higher memory usage than expected; one example is adding a
- lot of nodes, and them removing all even numbered ones; not a single page
- is reclaimed in the process. However this is an example specifically crafted
- to produce unsatisfying behavior; in all practical usage scenarios the
- memory consumption is less than that of a general-purpose allocator because
- allocation meta-data is very small in size.
- </p>
-</div>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <b>Object model</b> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="install.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="loading.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/install.html b/docs/manual/install.html
deleted file mode 100644
index af662c1..0000000
--- a/docs/manual/install.html
+++ /dev/null
@@ -1,517 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Installation</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="../manual.html" title="pugixml 1.5">
-<link rel="next" href="dom.html" title="Document object model">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <b>Installation</b> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="../manual.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="dom.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.install"></a><a class="link" href="install.html" title="Installation"> Installation</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="install.html#manual.install.getting"> Getting pugixml</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="install.html#manual.install.getting.source"> Source distributions</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.getting.git"> Git repository</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.getting.subversion"> Subversion repository</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="install.html#manual.install.building"> Building pugixml</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="install.html#manual.install.building.embed"> Building pugixml as
- a part of another static library/executable</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.static"> Building pugixml as
- a standalone static library</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.shared"> Building pugixml as
- a standalone shared library</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.header"> Using pugixml in header-only
- mode</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.config"> Additional configuration
- options</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="install.html#manual.install.portability"> Portability</a></span></dt>
-</dl></div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.install.getting"></a><a class="link" href="install.html#manual.install.getting" title="Getting pugixml"> Getting pugixml</a>
-</h3></div></div></div>
-<p>
- pugixml is distributed in source form. You can either download a source distribution
- or clone the Git repository.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.getting.source"></a><a class="link" href="install.html#manual.install.getting.source" title="Source distributions"> Source distributions</a>
-</h4></div></div></div>
-<p>
- You can download the latest source distribution via one of the following
- links:
- </p>
-<pre class="programlisting"><a href="https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.zip" target="_top">https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.zip</a>
-<a href="https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.tar.gz" target="_top">https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.tar.gz</a>
-</pre>
-<p>
- The distribution contains library source, documentation (the manual you're
- reading now and the quick start guide) and some code examples. After downloading
- the distribution, install pugixml by extracting all files from the compressed
- archive. The files have different line endings depending on the archive
- format - <code class="filename">.zip</code> archive has Windows line endings, <code class="filename">.tar.gz</code> archive has Unix
- line endings. Otherwise the files in both archives are identical.
- </p>
-<p>
- If you need an older version, you can download it from the <a href="https://github.com/zeux/pugixml/releases" target="_top">version
- archive</a>.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.getting.git"></a><a class="link" href="install.html#manual.install.getting.git" title="Git repository"> Git repository</a>
-</h4></div></div></div>
-<p>
- The Git repository is located at <a href="https://github.com/zeux/pugixml/" target="_top">https://github.com/zeux/pugixml/</a>.
- There is a Git tag "v{version}" for each version; also there
- is the "latest" tag, which always points to the latest stable
- release.
- </p>
-<p>
- For example, to checkout the current version, you can use this command:
- </p>
-<pre class="programlisting">git clone https://github.com/zeux/pugixml
-cd pugixml
-git checkout v1.5
-</pre>
-<p>
- The repository contains library source, documentation, code examples and
- full unit test suite.
- </p>
-<p>
- Use latest version tag if you want to automatically get new versions. Use
- other tags if you want to switch to new versions only explicitly. Also
- please note that the master branch contains the work-in-progress version
- of the code; while this means that you can get new features and bug fixes
- from master without waiting for a new release, this also means that occasionally
- the code can be broken in some configurations.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.getting.subversion"></a><a class="link" href="install.html#manual.install.getting.subversion" title="Subversion repository"> Subversion repository</a>
-</h4></div></div></div>
-<p>
- You can access the Git repository via Subversion using <a href="https://github.com/zeux/pugixml" target="_top">https://github.com/zeux/pugixml</a>
- URL. For example, to checkout the current version, you can use this command:
- </p>
-<pre class="programlisting">svn checkout https://github.com/zeux/pugixml/tags/v1.5 pugixml</pre>
-</div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.install.building"></a><a class="link" href="install.html#manual.install.building" title="Building pugixml"> Building pugixml</a>
-</h3></div></div></div>
-<p>
- pugixml is distributed in source form without any pre-built binaries; you
- have to build them yourself.
- </p>
-<p>
- The complete pugixml source consists of three files - one source file, <code class="filename">pugixml.cpp</code>,
- and two header files, <code class="filename">pugixml.hpp</code> and <code class="filename">pugiconfig.hpp</code>. <code class="filename">pugixml.hpp</code> is the primary
- header which you need to include in order to use pugixml classes/functions;
- <code class="filename">pugiconfig.hpp</code> is a supplementary configuration file (see <a class="xref" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration
- options</a>).
- The rest of this guide assumes that <code class="filename">pugixml.hpp</code> is either in the current directory
- or in one of include directories of your projects, so that <code class="computeroutput"><span class="preprocessor">#include</span> <span class="string">"pugixml.hpp"</span></code>
- can find the header; however you can also use relative path (i.e. <code class="computeroutput"><span class="preprocessor">#include</span> <span class="string">"../libs/pugixml/src/pugixml.hpp"</span></code>)
- or include directory-relative path (i.e. <code class="computeroutput"><span class="preprocessor">#include</span>
- <span class="special">&lt;</span><span class="identifier">xml</span><span class="special">/</span><span class="identifier">thirdparty</span><span class="special">/</span><span class="identifier">pugixml</span><span class="special">/</span><span class="identifier">src</span><span class="special">/</span><span class="identifier">pugixml</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>).
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.building.embed"></a><a class="link" href="install.html#manual.install.building.embed" title="Building pugixml as a part of another static library/executable"> Building pugixml as
- a part of another static library/executable</a>
-</h4></div></div></div>
-<p>
- The easiest way to build pugixml is to compile the source file, <code class="filename">pugixml.cpp</code>,
- along with the existing library/executable. This process depends on the
- method of building your application; for example, if you're using Microsoft
- Visual Studio<a href="#ftn.trademarks" class="footnote" name="trademarks"><sup class="footnote">[1]</sup></a>, Apple Xcode, Code::Blocks or any other IDE, just add <code class="filename">pugixml.cpp</code> to
- one of your projects.
- </p>
-<p>
- If you're using Microsoft Visual Studio and the project has precompiled
- headers turned on, you'll see the following error messages:
- </p>
-<pre class="programlisting">pugixml.cpp(3477) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?</pre>
-<p>
- The correct way to resolve this is to disable precompiled headers for <code class="filename">pugixml.cpp</code>;
- you have to set "Create/Use Precompiled Header" option (Properties
- dialog -&gt; C/C++ -&gt; Precompiled Headers -&gt; Create/Use Precompiled
- Header) to "Not Using Precompiled Headers". You'll have to do
- it for all project configurations/platforms (you can select Configuration
- "All Configurations" and Platform "All Platforms" before
- editing the option):
- </p>
-<div class="informaltable"><table class="table">
-<colgroup><col></colgroup>
-<tbody><tr><td>
- <p>
- <a href="../images/vs2005_pch1.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2005_pch1_thumb.png" alt="vs2005_pch1_thumb"></span></a> <span class="inlinemediaobject"><img src="../images/next.png" alt="next"></span> <a href="../images/vs2005_pch2.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2005_pch2_thumb.png" alt="vs2005_pch2_thumb"></span></a> <span class="inlinemediaobject"><img src="../images/next.png" alt="next"></span> <a href="../images/vs2005_pch3.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2005_pch3_thumb.png" alt="vs2005_pch3_thumb"></span></a> <span class="inlinemediaobject"><img src="../images/next.png" alt="next"></span> <a href="../images/vs2005_pch4.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2005_pch4_thumb.png" alt="vs2005_pch4_thumb"></span></a>
- </p>
- </td></tr></tbody>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.building.static"></a><a class="link" href="install.html#manual.install.building.static" title="Building pugixml as a standalone static library"> Building pugixml as
- a standalone static library</a>
-</h4></div></div></div>
-<p>
- It's possible to compile pugixml as a standalone static library. This process
- depends on the method of building your application; pugixml distribution
- comes with project files for several popular IDEs/build systems. There
- are project files for Apple XCode3, Code::Blocks, Codelite, Microsoft Visual
- Studio 2005, 2008, 2010, and configuration scripts for CMake and premake4.
- You're welcome to submit project files/build scripts for other software;
- see <a class="xref" href="../manual.html#manual.overview.feedback" title="Feedback"> Feedback</a>.
- </p>
-<p>
- There are two projects for each version of Microsoft Visual Studio: one
- for dynamically linked CRT, which has a name like <code class="filename">pugixml_vs2008.vcproj</code>,
- and another one for statically linked CRT, which has a name like <code class="filename">pugixml_vs2008_static.vcproj</code>.
- You should select the version that matches the CRT used in your application;
- the default option for new projects created by Microsoft Visual Studio
- is dynamically linked CRT, so unless you changed the defaults, you should
- use the version with dynamic CRT (i.e. <code class="filename">pugixml_vs2008.vcproj</code> for Microsoft
- Visual Studio 2008).
- </p>
-<p>
- In addition to adding pugixml project to your workspace, you'll have to
- make sure that your application links with pugixml library. If you're using
- Microsoft Visual Studio 2005/2008, you can add a dependency from your application
- project to pugixml one. If you're using Microsoft Visual Studio 2010, you'll
- have to add a reference to your application project instead. For other
- IDEs/systems, consult the relevant documentation.
- </p>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Microsoft Visual Studio 2005/2008
- </p>
- </th>
-<th>
- <p>
- Microsoft Visual Studio 2010
- </p>
- </th>
-</tr></thead>
-<tbody><tr>
-<td>
- <p>
- <a href="../images/vs2005_link1.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2005_link1_thumb.png" alt="vs2005_link1_thumb"></span></a> <span class="inlinemediaobject"><img src="../images/next.png" alt="next"></span> <a href="../images/vs2005_link2.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2005_link2_thumb.png" alt="vs2005_link2_thumb"></span></a>
- </p>
- </td>
-<td>
- <p>
- <a href="../images/vs2010_link1.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2010_link1_thumb.png" alt="vs2010_link1_thumb"></span></a> <span class="inlinemediaobject"><img src="../images/next.png" alt="next"></span> <a href="../images/vs2010_link2.png" target="_top"><span class="inlinemediaobject"><img src="../images/vs2010_link2_thumb.png" alt="vs2010_link2_thumb"></span></a>
- </p>
- </td>
-</tr></tbody>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.building.shared"></a><a class="link" href="install.html#manual.install.building.shared" title="Building pugixml as a standalone shared library"> Building pugixml as
- a standalone shared library</a>
-</h4></div></div></div>
-<p>
- It's possible to compile pugixml as a standalone shared library. The process
- is usually similar to the static library approach; however, no preconfigured
- projects/scripts are included into pugixml distribution, so you'll have
- to do it yourself. Generally, if you're using GCC-based toolchain, the
- process does not differ from building any other library as DLL (adding
- -shared to compilation flags should suffice); if you're using MSVC-based
- toolchain, you'll have to explicitly mark exported symbols with a declspec
- attribute. You can do it by defining <a class="link" href="install.html#PUGIXML_API">PUGIXML_API</a>
- macro, i.e. via <code class="filename">pugiconfig.hpp</code>:
- </p>
-<pre class="programlisting"><span class="preprocessor">#ifdef</span> <span class="identifier">_DLL</span>
-<span class="preprocessor">#define</span> <span class="identifier">PUGIXML_API</span> <span class="identifier">__declspec</span><span class="special">(</span><span class="identifier">dllexport</span><span class="special">)</span>
-<span class="preprocessor">#else</span>
-<span class="preprocessor">#define</span> <span class="identifier">PUGIXML_API</span> <span class="identifier">__declspec</span><span class="special">(</span><span class="identifier">dllimport</span><span class="special">)</span>
-<span class="preprocessor">#endif</span>
-</pre>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- If you're using STL-related functions, you should use the shared runtime
- library to ensure that a single heap is used for STL allocations in your
- application and in pugixml; in MSVC, this means selecting the 'Multithreaded
- DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (/MD
- or /MDd linker switch). You should also make sure that your runtime library
- choice is consistent between different projects.
- </p></td></tr>
-</table></div>
-</div>
-<a name="PUGIXML_HEADER_ONLY"></a><div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.building.header"></a><a class="link" href="install.html#manual.install.building.header" title="Using pugixml in header-only mode"> Using pugixml in header-only
- mode</a>
-</h4></div></div></div>
-<p>
- It's possible to use pugixml in header-only mode. This means that all source
- code for pugixml will be included in every translation unit that includes
- <code class="filename">pugixml.hpp</code>. This is how most of Boost and STL libraries work.
- </p>
-<p>
- Note that there are advantages and drawbacks of this approach. Header mode
- may improve tree traversal/modification performance (because many simple
- functions will be inlined), if your compiler toolchain does not support
- link-time optimization, or if you have it turned off (with link-time optimization
- the performance should be similar to non-header mode). However, since compiler
- now has to compile pugixml source once for each translation unit that includes
- it, compilation times may increase noticeably. If you want to use pugixml
- in header mode but do not need XPath support, you can consider disabling
- it by using <a class="link" href="install.html#PUGIXML_NO_XPATH">PUGIXML_NO_XPATH</a> define
- to improve compilation time.
- </p>
-<p>
- Enabling header-only mode is a two-step process:
- </p>
-<div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- You have to define <code class="computeroutput"><span class="identifier">PUGIXML_HEADER_ONLY</span></code>
- </li>
-<li class="listitem">
- You have to include <code class="filename">pugixml.cpp</code> whenever you include pugixml.hpp
- </li>
-</ol></div>
-<p>
- Both of these are best done via <code class="filename">pugiconfig.hpp</code> like this:
- </p>
-<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">PUGIXML_HEADER_ONLY</span>
-<span class="preprocessor">#include</span> <span class="string">"pugixml.cpp"</span>
-</pre>
-<p>
- Note that it is safe to compile <code class="filename">pugixml.cpp</code> if <code class="computeroutput"><span class="identifier">PUGIXML_HEADER_ONLY</span></code>
- is defined - so if you want to i.e. use header-only mode only in Release
- configuration, you can include pugixml.cpp in your project (see <a class="xref" href="install.html#manual.install.building.embed" title="Building pugixml as a part of another static library/executable"> Building pugixml as
- a part of another static library/executable</a>),
- and conditionally enable header-only mode in <code class="filename">pugiconfig.hpp</code>, i.e.:
- </p>
-<pre class="programlisting"><span class="preprocessor">#ifndef</span> <span class="identifier">_DEBUG</span>
- <span class="preprocessor">#define</span> <span class="identifier">PUGIXML_HEADER_ONLY</span>
- <span class="preprocessor">#include</span> <span class="string">"pugixml.cpp"</span>
-<span class="preprocessor">#endif</span>
-</pre>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="manual.install.building.config"></a><a class="link" href="install.html#manual.install.building.config" title="Additional configuration options"> Additional configuration
- options</a>
-</h4></div></div></div>
-<p>
- pugixml uses several defines to control the compilation process. There
- are two ways to define them: either put the needed definitions to <code class="filename">pugiconfig.hpp</code> (it
- has some examples that are commented out) or provide them via compiler
- command-line. Consistency is important: the definitions should match in
- all source files that include <code class="filename">pugixml.hpp</code> (including pugixml sources) throughout
- the application. Adding defines to <code class="filename">pugiconfig.hpp</code> lets you guarantee this,
- unless your macro definition is wrapped in preprocessor <code class="computeroutput"><span class="preprocessor">#if</span></code>/<code class="computeroutput"><span class="preprocessor">#ifdef</span></code> directive and this directive
- is not consistent. <code class="filename">pugiconfig.hpp</code> will never contain anything but comments,
- which means that when upgrading to a new version, you can safely leave
- your modified version intact.
- </p>
-<p>
- <a name="PUGIXML_WCHAR_MODE"></a><code class="literal">PUGIXML_WCHAR_MODE</code> define toggles
- between UTF-8 style interface (the in-memory text encoding is assumed to
- be UTF-8, most functions use <code class="computeroutput"><span class="keyword">char</span></code>
- as character type) and UTF-16/32 style interface (the in-memory text encoding
- is assumed to be UTF-16/32, depending on <code class="computeroutput"><span class="keyword">wchar_t</span></code>
- size, most functions use <code class="computeroutput"><span class="keyword">wchar_t</span></code>
- as character type). See <a class="xref" href="dom.html#manual.dom.unicode" title="Unicode interface"> Unicode interface</a> for more details.
- </p>
-<p>
- <a name="PUGIXML_NO_XPATH"></a><code class="literal">PUGIXML_NO_XPATH</code> define disables XPath.
- Both XPath interfaces and XPath implementation are excluded from compilation.
- This option is provided in case you do not need XPath functionality and
- need to save code space.
- </p>
-<p>
- <a name="PUGIXML_NO_STL"></a><code class="literal">PUGIXML_NO_STL</code> define disables use of
- STL in pugixml. The functions that operate on STL types are no longer present
- (i.e. load/save via iostream) if this macro is defined. This option is
- provided in case your target platform does not have a standard-compliant
- STL implementation.
- </p>
-<p>
- <a name="PUGIXML_NO_EXCEPTIONS"></a><code class="literal">PUGIXML_NO_EXCEPTIONS</code> define disables
- use of exceptions in pugixml. This option is provided in case your target
- platform does not have exception handling capabilities.
- </p>
-<p>
- <a name="PUGIXML_API"></a><code class="literal">PUGIXML_API</code>, <a name="PUGIXML_CLASS"></a><code class="literal">PUGIXML_CLASS</code>
- and <a name="PUGIXML_FUNCTION"></a><code class="literal">PUGIXML_FUNCTION</code> defines let you
- specify custom attributes (i.e. declspec or calling conventions) for pugixml
- classes and non-member functions. In absence of <code class="computeroutput"><span class="identifier">PUGIXML_CLASS</span></code>
- or <code class="computeroutput"><span class="identifier">PUGIXML_FUNCTION</span></code> definitions,
- <code class="computeroutput"><span class="identifier">PUGIXML_API</span></code> definition
- is used instead. For example, to specify fixed calling convention, you
- can define <code class="computeroutput"><span class="identifier">PUGIXML_FUNCTION</span></code>
- to i.e. <code class="computeroutput"><span class="identifier">__fastcall</span></code>. Another
- example is DLL import/export attributes in MSVC (see <a class="xref" href="install.html#manual.install.building.shared" title="Building pugixml as a standalone shared library"> Building pugixml as
- a standalone shared library</a>).
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- In that example <code class="computeroutput"><span class="identifier">PUGIXML_API</span></code>
- is inconsistent between several source files; this is an exception to
- the consistency rule.
- </p></td></tr>
-</table></div>
-<p>
- <a name="PUGIXML_MEMORY_PAGE_SIZE"></a><code class="literal">PUGIXML_MEMORY_PAGE_SIZE</code>, <a name="PUGIXML_MEMORY_OUTPUT_STACK"></a><code class="literal">PUGIXML_MEMORY_OUTPUT_STACK</code>
- and <a name="PUGIXML_MEMORY_XPATH_PAGE_SIZE"></a><code class="literal">PUGIXML_MEMORY_XPATH_PAGE_SIZE</code>
- can be used to customize certain important sizes to optimize memory usage
- for the application-specific patterns. For details see <a class="xref" href="dom.html#manual.dom.memory.tuning" title="Memory consumption tuning"> Memory consumption tuning</a>.
- </p>
-<p>
- <a name="PUGIXML_HAS_LONG_LONG"></a><code class="literal">PUGIXML_HAS_LONG_LONG</code> define enables
- support for <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>
- type in pugixml. This define is automatically enabled if your platform
- is known to have <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>
- support (i.e. has C++-11 support or uses a reasonably modern version of
- a known compiler); if pugixml does not recognize that your platform supports
- <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>
- but in fact it does, you can enable the define manually.
- </p>
-</div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.install.portability"></a><a class="link" href="install.html#manual.install.portability" title="Portability"> Portability</a>
-</h3></div></div></div>
-<p>
- pugixml is written in standard-compliant C++ with some compiler-specific
- workarounds where appropriate. pugixml is compatible with the C++11 standard,
- but does not require C++11 support. Each version is tested with a unit test
- suite (with code coverage about 99%) on the following platforms:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Microsoft Windows:
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- Borland C++ Compiler 5.82
- </li>
-<li class="listitem">
- Digital Mars C++ Compiler 8.51
- </li>
-<li class="listitem">
- Intel C++ Compiler 8.0, 9.0 x86/x64, 10.0 x86/x64, 11.0 x86/x64
- </li>
-<li class="listitem">
- Metrowerks CodeWarrior 8.0
- </li>
-<li class="listitem">
- Microsoft Visual C++ 6.0, 7.0 (2002), 7.1 (2003), 8.0 (2005) x86/x64,
- 9.0 (2008) x86/x64, 10.0 (2010) x86/x64, 11.0 (2011) x86/x64/ARM,
- 12.0 (2013) x86/x64/ARM and some CLR versions
- </li>
-<li class="listitem">
- MinGW (GCC) 3.4, 4.4, 4.5, 4.6 x64
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- Linux (GCC 4.4.3 x86/x64, GCC 4.8.1 x64, Clang 3.2 x64)
- </li>
-<li class="listitem">
- FreeBSD (GCC 4.2.1 x86/x64)
- </li>
-<li class="listitem">
- Apple MacOSX (GCC 4.0.1 x86/x64/PowerPC)
- </li>
-<li class="listitem">
- Sun Solaris (sunCC x86/x64)
- </li>
-<li class="listitem">
- Microsoft Xbox 360
- </li>
-<li class="listitem">
- Nintendo Wii (Metrowerks CodeWarrior 4.1)
- </li>
-<li class="listitem">
- Sony Playstation Portable (GCC 3.4.2)
- </li>
-<li class="listitem">
- Sony Playstation 3 (GCC 4.1.1, SNC 310.1)
- </li>
-<li class="listitem">
- Various portable platforms (Android NDK, BlackBerry NDK, Samsung bada,
- Windows CE)
- </li>
-</ul></div>
-</div>
-<div class="footnotes">
-<br><hr style="width:100; text-align:left;margin-left: 0">
-<div id="ftn.trademarks" class="footnote"><p><a href="#trademarks" class="para"><sup class="para">[1] </sup></a>All trademarks used are properties of their respective
- owners.</p></div>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <b>Installation</b> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="../manual.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="dom.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/loading.html b/docs/manual/loading.html
deleted file mode 100644
index d302f73..0000000
--- a/docs/manual/loading.html
+++ /dev/null
@@ -1,914 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Loading document</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="dom.html" title="Document object model">
-<link rel="next" href="access.html" title="Accessing document data">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <b>Loading</b> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="dom.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="access.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.loading"></a><a class="link" href="loading.html" title="Loading document"> Loading document</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="loading.html#manual.loading.file"> Loading document from file</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.memory"> Loading document from memory</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.stream"> Loading document from C++ IOstreams</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.errors"> Handling parsing errors</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.options"> Parsing options</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.encoding"> Encodings</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.w3c"> Conformance to W3C specification</a></span></dt>
-</dl></div>
-<p>
- pugixml provides several functions for loading XML data from various places
- - files, C++ iostreams, memory buffers. All functions use an extremely fast
- non-validating parser. This parser is not fully W3C conformant - it can load
- any valid XML document, but does not perform some well-formedness checks. While
- considerable effort is made to reject invalid XML documents, some validation
- is not performed for performance reasons. Also some XML transformations (i.e.
- EOL handling or attribute value normalization) can impact parsing speed and
- thus can be disabled. However for vast majority of XML documents there is no
- performance difference between different parsing options. Parsing options also
- control whether certain XML nodes are parsed; see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a> for
- more information.
- </p>
-<p>
- XML data is always converted to internal character format (see <a class="xref" href="dom.html#manual.dom.unicode" title="Unicode interface"> Unicode interface</a>)
- before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16
- (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally
- supported since it's a strict subset of UTF-16) and handles all encoding conversions
- automatically. Unless explicit encoding is specified, loading functions perform
- automatic encoding detection based on first few characters of XML data, so
- in almost all cases you do not have to specify document encoding. Encoding
- conversion is described in more detail in <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.file"></a><a class="link" href="loading.html#manual.loading.file" title="Loading document from file"> Loading document from file</a>
-</h3></div></div></div>
-<a name="xml_document::load_file"></a><a name="xml_document::load_file_wide"></a><p>
- The most common source of XML data is files; pugixml provides dedicated functions
- for loading an XML document from file:
- </p>
-<pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-<span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-</pre>
-<p>
- These functions accept the file path as its first argument, and also two
- optional arguments, which specify parsing options (see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a>)
- and input data encoding (see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>). The path has the target
- operating system format, so it can be a relative or absolute one, it should
- have the delimiters of the target system, it should have the exact case if
- the target file system is case-sensitive, etc.
- </p>
-<p>
- File path is passed to the system file opening function as is in case of
- the first function (which accepts <code class="computeroutput"><span class="keyword">const</span>
- <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span></code>); the second function either uses
- a special file opening function if it is provided by the runtime library
- or converts the path to UTF-8 and uses the system file opening function.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">load_file</span></code> destroys the existing
- document tree and then tries to load the new tree from the specified file.
- The result of the operation is returned in an <a class="link" href="loading.html#xml_parse_result">xml_parse_result</a>
- object; this object contains the operation status and the related information
- (i.e. last successfully parsed position in the input file, if parsing fails).
- See <a class="xref" href="loading.html#manual.loading.errors" title="Handling parsing errors"> Handling parsing errors</a> for error handling details.
- </p>
-<p>
- This is an example of loading XML document from file (<a href="../samples/load_file.cpp" target="_top">samples/load_file.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="string">"tree.xml"</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Load result: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">description</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">", mesh name: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"mesh"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.memory"></a><a class="link" href="loading.html#manual.loading.memory" title="Loading document from memory"> Loading document from memory</a>
-</h3></div></div></div>
-<a name="xml_document::load_buffer"></a><a name="xml_document::load_buffer_inplace"></a><a name="xml_document::load_buffer_inplace_own"></a><p>
- Sometimes XML data should be loaded from some other source than a file, i.e.
- HTTP URL; also you may want to load XML data from file using non-standard
- functions, i.e. to use your virtual file system facilities or to load XML
- from gzip-compressed files. All these scenarios require loading document
- from memory. First you should prepare a contiguous memory block with all
- XML data; then you have to invoke one of buffer loading functions. These
- functions will handle the necessary encoding conversions, if any, and then
- will parse the data into the corresponding XML tree. There are several buffer
- loading functions, which differ in the behavior and thus in performance/memory
- usage:
- </p>
-<pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-<span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-<span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_buffer_inplace_own</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-</pre>
-<p>
- All functions accept the buffer which is represented by a pointer to XML
- data, <code class="computeroutput"><span class="identifier">contents</span></code>, and data
- size in bytes. Also there are two optional arguments, which specify parsing
- options (see <a class="xref" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a>) and input data encoding (see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>).
- The buffer does not have to be zero-terminated.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">load_buffer</span></code> function works
- with immutable buffer - it does not ever modify the buffer. Because of this
- restriction it has to create a private buffer and copy XML data to it before
- parsing (applying encoding conversions if necessary). This copy operation
- carries a performance penalty, so inplace functions are provided - <code class="computeroutput"><span class="identifier">load_buffer_inplace</span></code> and <code class="computeroutput"><span class="identifier">load_buffer_inplace_own</span></code>
- store the document data in the buffer, modifying it in the process. In order
- for the document to stay valid, you have to make sure that the buffer's lifetime
- exceeds that of the tree if you're using inplace functions. In addition to
- that, <code class="computeroutput"><span class="identifier">load_buffer_inplace</span></code>
- does not assume ownership of the buffer, so you'll have to destroy it yourself;
- <code class="computeroutput"><span class="identifier">load_buffer_inplace_own</span></code> assumes
- ownership of the buffer and destroys it once it is not needed. This means
- that if you're using <code class="computeroutput"><span class="identifier">load_buffer_inplace_own</span></code>,
- you have to allocate memory with pugixml allocation function (you can get
- it via <a class="link" href="dom.html#get_memory_allocation_function">get_memory_allocation_function</a>).
- </p>
-<p>
- The best way from the performance/memory point of view is to load document
- using <code class="computeroutput"><span class="identifier">load_buffer_inplace_own</span></code>;
- this function has maximum control of the buffer with XML data so it is able
- to avoid redundant copies and reduce peak memory usage while parsing. This
- is the recommended function if you have to load the document from memory
- and performance is critical.
- </p>
-<a name="xml_document::load_string"></a><p>
- There is also a simple helper function for cases when you want to load the
- XML document from null-terminated character string:
- </p>
-<pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_string</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">);</span>
-</pre>
-<p>
- It is equivalent to calling <code class="computeroutput"><span class="identifier">load_buffer</span></code>
- with <code class="computeroutput"><span class="identifier">size</span></code> being either <code class="computeroutput"><span class="identifier">strlen</span><span class="special">(</span><span class="identifier">contents</span><span class="special">)</span></code>
- or <code class="computeroutput"><span class="identifier">wcslen</span><span class="special">(</span><span class="identifier">contents</span><span class="special">)</span> <span class="special">*</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">wchar_t</span><span class="special">)</span></code>,
- depending on the character type. This function assumes native encoding for
- input data, so it does not do any encoding conversion. In general, this function
- is fine for loading small documents from string literals, but has more overhead
- and less functionality than the buffer loading functions.
- </p>
-<p>
- This is an example of loading XML document from memory using different functions
- (<a href="../samples/load_memory.cpp" target="_top">samples/load_memory.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="keyword">char</span> <span class="identifier">source</span><span class="special">[]</span> <span class="special">=</span> <span class="string">"&lt;mesh name='sphere'&gt;&lt;bounds&gt;0 0 1 1&lt;/bounds&gt;&lt;/mesh&gt;"</span><span class="special">;</span>
-<span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// You can use load_buffer to load document from immutable memory block:
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document
-</span><span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">char</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span>
-<span class="identifier">memcpy</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-
-<span class="comment">// The block can be allocated by any method; the block is modified during parsing
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-
-<span class="comment">// You have to destroy the block yourself after the document is no longer used
-</span><span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">buffer</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block
-</span><span class="comment">// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect
-</span><span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">char</span><span class="special">*&gt;(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">get_memory_allocation_function</span><span class="special">()(</span><span class="identifier">size</span><span class="special">));</span>
-<span class="identifier">memcpy</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-
-<span class="comment">// The block will be deleted by the document
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace_own</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// You can use load to load document from null-terminated strings, for example literals:
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="string">"&lt;mesh name='sphere'&gt;&lt;bounds&gt;0 0 1 1&lt;/bounds&gt;&lt;/mesh&gt;"</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.stream"></a><a class="link" href="loading.html#manual.loading.stream" title="Loading document from C++ IOstreams"> Loading document from C++ IOstreams</a>
-</h3></div></div></div>
-<a name="xml_document::load_stream"></a><p>
- To enhance interoperability, pugixml provides functions for loading document
- from any object which implements C++ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span></code>
- interface. This allows you to load documents from any standard C++ stream
- (i.e. file stream) or any third-party compliant implementation (i.e. Boost
- Iostreams). There are two functions, one works with narrow character streams,
- another handles wide character ones:
- </p>
-<pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-<span class="identifier">xml_parse_result</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wistream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">);</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">load</span></code> with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span></code>
- argument loads the document from stream from the current read position to
- the end, treating the stream contents as a byte stream of the specified encoding
- (with encoding autodetection as necessary). Thus calling <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span></code>
- on an opened <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ifstream</span></code> object is equivalent to calling
- <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load_file</span></code>.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">load</span></code> with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstream</span></code>
- argument treats the stream contents as a wide character stream (encoding
- is always <a class="link" href="loading.html#encoding_wchar">encoding_wchar</a>). Because
- of this, using <code class="computeroutput"><span class="identifier">load</span></code> with
- wide character streams requires careful (usually platform-specific) stream
- setup (i.e. using the <code class="computeroutput"><span class="identifier">imbue</span></code>
- function). Generally use of wide streams is discouraged, however it provides
- you the ability to load documents from non-Unicode encodings, i.e. you can
- load Shift-JIS encoded data if you set the correct locale.
- </p>
-<p>
- This is a simple example of loading XML document from file using streams
- (<a href="../samples/load_stream.cpp" target="_top">samples/load_stream.cpp</a>); read
- the sample code for more complex examples involving wide streams and locales:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ifstream</span> <span class="identifier">stream</span><span class="special">(</span><span class="string">"weekly-utf-8.xml"</span><span class="special">);</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">stream</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.errors"></a><a class="link" href="loading.html#manual.loading.errors" title="Handling parsing errors"> Handling parsing errors</a>
-</h3></div></div></div>
-<a name="xml_parse_result"></a><p>
- All document loading functions return the parsing result via <code class="computeroutput"><span class="identifier">xml_parse_result</span></code> object. It contains parsing
- status, the offset of last successfully parsed character from the beginning
- of the source stream, and the encoding of the source stream:
- </p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xml_parse_result</span>
-<span class="special">{</span>
- <span class="identifier">xml_parse_status</span> <span class="identifier">status</span><span class="special">;</span>
- <span class="identifier">ptrdiff_t</span> <span class="identifier">offset</span><span class="special">;</span>
- <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span><span class="special">;</span>
-
- <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
- <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">description</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="special">};</span>
-</pre>
-<a name="xml_parse_status"></a><a name="xml_parse_result::status"></a><p>
- Parsing status is represented as the <code class="computeroutput"><span class="identifier">xml_parse_status</span></code>
- enumeration and can be one of the following:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="status_ok"></a><code class="literal">status_ok</code> means that no error was encountered
- during parsing; the source stream represents the valid XML document which
- was fully parsed and converted to a tree. <br><br>
-
- </li>
-<li class="listitem">
- <a name="status_file_not_found"></a><code class="literal">status_file_not_found</code> is only
- returned by <code class="computeroutput"><span class="identifier">load_file</span></code>
- function and means that file could not be opened.
- </li>
-<li class="listitem">
- <a name="status_io_error"></a><code class="literal">status_io_error</code> is returned by <code class="computeroutput"><span class="identifier">load_file</span></code> function and by <code class="computeroutput"><span class="identifier">load</span></code> functions with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span></code>/<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstream</span></code> arguments; it means that some
- I/O error has occurred during reading the file/stream.
- </li>
-<li class="listitem">
- <a name="status_out_of_memory"></a><code class="literal">status_out_of_memory</code> means that
- there was not enough memory during some allocation; any allocation failure
- during parsing results in this error.
- </li>
-<li class="listitem">
- <a name="status_internal_error"></a><code class="literal">status_internal_error</code> means that
- something went horribly wrong; currently this error does not occur <br><br>
-
- </li>
-<li class="listitem">
- <a name="status_unrecognized_tag"></a><code class="literal">status_unrecognized_tag</code> means
- that parsing stopped due to a tag with either an empty name or a name
- which starts with incorrect character, such as <code class="literal">#</code>.
- </li>
-<li class="listitem">
- <a name="status_bad_pi"></a><code class="literal">status_bad_pi</code> means that parsing stopped
- due to incorrect document declaration/processing instruction
- </li>
-<li class="listitem">
- <a name="status_bad_comment"></a><code class="literal">status_bad_comment</code>, <a name="status_bad_cdata"></a><code class="literal">status_bad_cdata</code>,
- <a name="status_bad_doctype"></a><code class="literal">status_bad_doctype</code> and <a name="status_bad_pcdata"></a><code class="literal">status_bad_pcdata</code>
- mean that parsing stopped due to the invalid construct of the respective
- type
- </li>
-<li class="listitem">
- <a name="status_bad_start_element"></a><code class="literal">status_bad_start_element</code> means
- that parsing stopped because starting tag either had no closing <code class="computeroutput"><span class="special">&gt;</span></code> symbol or contained some incorrect
- symbol
- </li>
-<li class="listitem">
- <a name="status_bad_attribute"></a><code class="literal">status_bad_attribute</code> means that
- parsing stopped because there was an incorrect attribute, such as an
- attribute without value or with value that is not quoted (note that
- <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span>
- <span class="identifier">attr</span><span class="special">=</span><span class="number">1</span><span class="special">&gt;</span></code> is
- incorrect in XML)
- </li>
-<li class="listitem">
- <a name="status_bad_end_element"></a><code class="literal">status_bad_end_element</code> means
- that parsing stopped because ending tag had incorrect syntax (i.e. extra
- non-whitespace symbols between tag name and <code class="computeroutput"><span class="special">&gt;</span></code>)
- </li>
-<li class="listitem">
- <a name="status_end_element_mismatch"></a><code class="literal">status_end_element_mismatch</code>
- means that parsing stopped because the closing tag did not match the
- opening one (i.e. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;&lt;/</span><span class="identifier">nedo</span><span class="special">&gt;</span></code>) or because some tag was not closed
- at all
- </li>
-<li class="listitem">
- <a name="status_no_document_element"></a><code class="literal">status_no_document_element</code>
- means that no element nodes were discovered during parsing; this usually
- indicates an empty or invalid document
- </li>
-</ul></div>
-<a name="xml_parse_result::description"></a><p>
- <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code>
- member function can be used to convert parsing status to a string; the returned
- message is always in English, so you'll have to write your own function if
- you need a localized string. However please note that the exact messages
- returned by <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code>
- function may change from version to version, so any complex status handling
- should be based on <code class="computeroutput"><span class="identifier">status</span></code>
- value. Note that <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> returns a <code class="computeroutput"><span class="keyword">char</span></code>
- string even in <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>;
- you'll have to call <a class="link" href="dom.html#as_wide">as_wide</a> to get the <code class="computeroutput"><span class="keyword">wchar_t</span></code> string.
- </p>
-<p>
- If parsing failed because the source data was not a valid XML, the resulting
- tree is not destroyed - despite the fact that load function returns error,
- you can use the part of the tree that was successfully parsed. Obviously,
- the last element may have an unexpected name/value; for example, if the attribute
- value does not end with the necessary quotation mark, like in <code class="literal">&lt;node
- attr="value&gt;some data&lt;/node&gt;</code> example, the value of
- attribute <code class="computeroutput"><span class="identifier">attr</span></code> will contain
- the string <code class="computeroutput"><span class="identifier">value</span><span class="special">&gt;</span><span class="identifier">some</span> <span class="identifier">data</span><span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>.
- </p>
-<a name="xml_parse_result::offset"></a><p>
- In addition to the status code, parsing result has an <code class="computeroutput"><span class="identifier">offset</span></code>
- member, which contains the offset of last successfully parsed character if
- parsing failed because of an error in source data; otherwise <code class="computeroutput"><span class="identifier">offset</span></code> is 0. For parsing efficiency reasons,
- pugixml does not track the current line during parsing; this offset is in
- units of <a class="link" href="dom.html#char_t">pugi::char_t</a> (bytes for character
- mode, wide characters for wide character mode). Many text editors support
- 'Go To Position' feature - you can use it to locate the exact error position.
- Alternatively, if you're loading the document from memory, you can display
- the error chunk along with the error description (see the example code below).
- </p>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Offset is calculated in the XML buffer in native encoding; if encoding
- conversion is performed during parsing, offset can not be used to reliably
- track the error position.
- </p></td></tr>
-</table></div>
-<a name="xml_parse_result::encoding"></a><p>
- Parsing result also has an <code class="computeroutput"><span class="identifier">encoding</span></code>
- member, which can be used to check that the source data encoding was correctly
- guessed. It is equal to the exact encoding used during parsing (i.e. with
- the exact endianness); see <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a> for more information.
- </p>
-<a name="xml_parse_result::bool"></a><p>
- Parsing result object can be implicitly converted to <code class="computeroutput"><span class="keyword">bool</span></code>;
- if you do not want to handle parsing errors thoroughly, you can just check
- the return value of load functions as if it was a <code class="computeroutput"><span class="keyword">bool</span></code>:
- <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="string">"file.xml"</span><span class="special">))</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>.
- </p>
-<p>
- This is an example of handling loading errors (<a href="../samples/load_error_handling.cpp" target="_top">samples/load_error_handling.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span>
-
-<span class="keyword">if</span> <span class="special">(</span><span class="identifier">result</span><span class="special">)</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"XML ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">source</span> <span class="special">&lt;&lt;</span> <span class="string">"] parsed without errors, attr value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"attr"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n\n"</span><span class="special">;</span>
-<span class="keyword">else</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"XML ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">source</span> <span class="special">&lt;&lt;</span> <span class="string">"] parsed with errors, attr value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"attr"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n"</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Error description: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">description</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Error offset: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">offset</span> <span class="special">&lt;&lt;</span> <span class="string">" (error at [..."</span> <span class="special">&lt;&lt;</span> <span class="special">(</span><span class="identifier">source</span> <span class="special">+</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">offset</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n\n"</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.options"></a><a class="link" href="loading.html#manual.loading.options" title="Parsing options"> Parsing options</a>
-</h3></div></div></div>
-<p>
- All document loading functions accept the optional parameter <code class="computeroutput"><span class="identifier">options</span></code>. This is a bitmask that customizes
- the parsing process: you can select the node types that are parsed and various
- transformations that are performed with the XML text. Disabling certain transformations
- can improve parsing performance for some documents; however, the code for
- all transformations is very well optimized, and thus the majority of documents
- won't get any performance benefit. As a rule of thumb, only modify parsing
- flags if you want to get some nodes in the document that are excluded by
- default (i.e. declaration or comment nodes).
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- You should use the usual bitwise arithmetics to manipulate the bitmask:
- to enable a flag, use <code class="computeroutput"><span class="identifier">mask</span> <span class="special">|</span> <span class="identifier">flag</span></code>;
- to disable a flag, use <code class="computeroutput"><span class="identifier">mask</span> <span class="special">&amp;</span> <span class="special">~</span><span class="identifier">flag</span></code>.
- </p></td></tr>
-</table></div>
-<p>
- These flags control the resulting tree contents:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="parse_declaration"></a><code class="literal">parse_declaration</code> determines if XML
- document declaration (node with type <a class="link" href="dom.html#node_declaration">node_declaration</a>)
- is to be put in DOM tree. If this flag is off, it is not put in the tree,
- but is still parsed and checked for correctness. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_doctype"></a><code class="literal">parse_doctype</code> determines if XML document
- type declaration (node with type <a class="link" href="dom.html#node_doctype">node_doctype</a>)
- is to be put in DOM tree. If this flag is off, it is not put in the tree,
- but is still parsed and checked for correctness. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_pi"></a><code class="literal">parse_pi</code> determines if processing instructions
- (nodes with type <a class="link" href="dom.html#node_pi">node_pi</a>) are to be put
- in DOM tree. If this flag is off, they are not put in the tree, but are
- still parsed and checked for correctness. Note that <code class="computeroutput"><span class="special">&lt;?</span><span class="identifier">xml</span> <span class="special">...?&gt;</span></code>
- (document declaration) is not considered to be a PI. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_comments"></a><code class="literal">parse_comments</code> determines if comments
- (nodes with type <a class="link" href="dom.html#node_comment">node_comment</a>) are
- to be put in DOM tree. If this flag is off, they are not put in the tree,
- but are still parsed and checked for correctness. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_cdata"></a><code class="literal">parse_cdata</code> determines if CDATA sections
- (nodes with type <a class="link" href="dom.html#node_cdata">node_cdata</a>) are to
- be put in DOM tree. If this flag is off, they are not put in the tree,
- but are still parsed and checked for correctness. This flag is <span class="bold"><strong>on</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_trim_pcdata"></a><code class="literal">parse_trim_pcdata</code> determines if leading
- and trailing whitespace characters are to be removed from PCDATA nodes.
- While for some applications leading/trailing whitespace is significant,
- often the application only cares about the non-whitespace contents so
- it's easier to trim whitespace from text during parsing. This flag is
- <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_ws_pcdata"></a><code class="literal">parse_ws_pcdata</code> determines if PCDATA
- nodes (nodes with type <a class="link" href="dom.html#node_pcdata">node_pcdata</a>)
- that consist only of whitespace characters are to be put in DOM tree.
- Often whitespace-only data is not significant for the application, and
- the cost of allocating and storing such nodes (both memory and speed-wise)
- can be significant. For example, after parsing XML string <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span> <span class="special">&lt;</span><span class="identifier">a</span><span class="special">/&gt;</span> <span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>, <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span></code>
- element will have three children when <code class="computeroutput"><span class="identifier">parse_ws_pcdata</span></code>
- is set (child with type <a class="link" href="dom.html#node_pcdata">node_pcdata</a>
- and value <code class="computeroutput"><span class="string">" "</span></code>,
- child with type <a class="link" href="dom.html#node_element">node_element</a> and
- name <code class="computeroutput"><span class="string">"a"</span></code>, and another
- child with type <a class="link" href="dom.html#node_pcdata">node_pcdata</a> and value
- <code class="computeroutput"><span class="string">" "</span></code>), and only
- one child when <code class="computeroutput"><span class="identifier">parse_ws_pcdata</span></code>
- is not set. This flag is <span class="bold"><strong>off</strong></span> by default.
- <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_ws_pcdata_single"></a><code class="literal">parse_ws_pcdata_single</code> determines
- if whitespace-only PCDATA nodes that have no sibling nodes are to be
- put in DOM tree. In some cases application needs to parse the whitespace-only
- contents of nodes, i.e. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span>
- <span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>, but is not interested in whitespace
- markup elsewhere. It is possible to use <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a>
- flag in this case, but it results in excessive allocations and complicates
- document processing in some cases; this flag is intended to avoid that.
- As an example, after parsing XML string <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span>
- <span class="special">&lt;</span><span class="identifier">a</span><span class="special">&gt;</span> <span class="special">&lt;/</span><span class="identifier">a</span><span class="special">&gt;</span> <span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code> with <code class="computeroutput"><span class="identifier">parse_ws_pcdata_single</span></code>
- flag set, <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span></code> element will have one child <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">&gt;</span></code>, and <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">a</span><span class="special">&gt;</span></code>
- element will have one child with type <a class="link" href="dom.html#node_pcdata">node_pcdata</a>
- and value <code class="computeroutput"><span class="string">" "</span></code>.
- This flag has no effect if <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a>
- is enabled. This flag is <span class="bold"><strong>off</strong></span> by default.
- <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_fragment"></a><code class="literal">parse_fragment</code> determines if document
- should be treated as a fragment of a valid XML. Parsing document as a
- fragment leads to top-level PCDATA content (i.e. text that is not located
- inside a node) to be added to a tree, and additionally treats documents
- without element nodes as valid. This flag is <span class="bold"><strong>off</strong></span>
- by default.
- </li>
-</ul></div>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Using in-place parsing (<a class="link" href="loading.html#xml_document::load_buffer_inplace">load_buffer_inplace</a>)
- with <code class="computeroutput"><span class="identifier">parse_fragment</span></code> flag
- may result in the loss of the last character of the buffer if it is a part
- of PCDATA. Since PCDATA values are null-terminated strings, the only way
- to resolve this is to provide a null-terminated buffer as an input to
- <code class="computeroutput"><span class="identifier">load_buffer_inplace</span></code> - i.e.
- <code class="computeroutput"><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="string">"test\0"</span><span class="special">,</span>
- <span class="number">5</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span>
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_fragment</span><span class="special">)</span></code>.
- </p></td></tr>
-</table></div>
-<p>
- These flags control the transformation of tree element contents:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="parse_escapes"></a><code class="literal">parse_escapes</code> determines if character
- and entity references are to be expanded during the parsing process.
- Character references have the form <code class="literal">&amp;#...;</code> or
- <code class="literal">&amp;#x...;</code> (<code class="literal">...</code> is Unicode numeric
- representation of character in either decimal (<code class="literal">&amp;#...;</code>)
- or hexadecimal (<code class="literal">&amp;#x...;</code>) form), entity references
- are <code class="literal">&amp;lt;</code>, <code class="literal">&amp;gt;</code>, <code class="literal">&amp;amp;</code>,
- <code class="literal">&amp;apos;</code> and <code class="literal">&amp;quot;</code> (note
- that as pugixml does not handle DTD, the only allowed entities are predefined
- ones). If character/entity reference can not be expanded, it is left
- as is, so you can do additional processing later. Reference expansion
- is performed on attribute values and PCDATA content. This flag is <span class="bold"><strong>on</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_eol"></a><code class="literal">parse_eol</code> determines if EOL handling (that
- is, replacing sequences <code class="computeroutput"><span class="number">0x0d</span> <span class="number">0x0a</span></code> by a single <code class="computeroutput"><span class="number">0x0a</span></code>
- character, and replacing all standalone <code class="computeroutput"><span class="number">0x0d</span></code>
- characters by <code class="computeroutput"><span class="number">0x0a</span></code>) is to
- be performed on input data (that is, comments contents, PCDATA/CDATA
- contents and attribute values). This flag is <span class="bold"><strong>on</strong></span>
- by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_wconv_attribute"></a><code class="literal">parse_wconv_attribute</code> determines
- if attribute value normalization should be performed for all attributes.
- This means, that whitespace characters (new line, tab and space) are
- replaced with space (<code class="computeroutput"><span class="char">' '</span></code>).
- New line characters are always treated as if <a class="link" href="loading.html#parse_eol">parse_eol</a>
- is set, i.e. <code class="computeroutput"><span class="special">\</span><span class="identifier">r</span><span class="special">\</span><span class="identifier">n</span></code>
- is converted to a single space. This flag is <span class="bold"><strong>on</strong></span>
- by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_wnorm_attribute"></a><code class="literal">parse_wnorm_attribute</code> determines
- if extended attribute value normalization should be performed for all
- attributes. This means, that after attribute values are normalized as
- if <a class="link" href="loading.html#parse_wconv_attribute">parse_wconv_attribute</a>
- was set, leading and trailing space characters are removed, and all sequences
- of space characters are replaced by a single space character. <a class="link" href="loading.html#parse_wconv_attribute">parse_wconv_attribute</a>
- has no effect if this flag is on. This flag is <span class="bold"><strong>off</strong></span>
- by default.
- </li>
-</ul></div>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- <code class="computeroutput"><span class="identifier">parse_wconv_attribute</span></code> option
- performs transformations that are required by W3C specification for attributes
- that are declared as <code class="literal">CDATA</code>; <a class="link" href="loading.html#parse_wnorm_attribute">parse_wnorm_attribute</a>
- performs transformations required for <code class="literal">NMTOKENS</code> attributes.
- In the absence of document type declaration all attributes should behave
- as if they are declared as <code class="literal">CDATA</code>, thus <a class="link" href="loading.html#parse_wconv_attribute">parse_wconv_attribute</a>
- is the default option.
- </p></td></tr>
-</table></div>
-<p>
- Additionally there are three predefined option masks:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="parse_minimal"></a><code class="literal">parse_minimal</code> has all options turned
- off. This option mask means that pugixml does not add declaration nodes,
- document type declaration nodes, PI nodes, CDATA sections and comments
- to the resulting tree and does not perform any conversion for input data,
- so theoretically it is the fastest mode. However, as mentioned above,
- in practice <a class="link" href="loading.html#parse_default">parse_default</a> is usually
- equally fast. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_default"></a><code class="literal">parse_default</code> is the default set of flags,
- i.e. it has all options set to their default values. It includes parsing
- CDATA sections (comments/PIs are not parsed), performing character and
- entity reference expansion, replacing whitespace characters with spaces
- in attribute values and performing EOL handling. Note, that PCDATA sections
- consisting only of whitespace characters are not parsed (by default)
- for performance reasons. <br><br>
-
- </li>
-<li class="listitem">
- <a name="parse_full"></a><code class="literal">parse_full</code> is the set of flags which adds
- nodes of all types to the resulting tree and performs default conversions
- for input data. It includes parsing CDATA sections, comments, PI nodes,
- document declaration node and document type declaration node, performing
- character and entity reference expansion, replacing whitespace characters
- with spaces in attribute values and performing EOL handling. Note, that
- PCDATA sections consisting only of whitespace characters are not parsed
- in this mode.
- </li>
-</ul></div>
-<p>
- This is an example of using different parsing options (<a href="../samples/load_options.cpp" target="_top">samples/load_options.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">source</span> <span class="special">=</span> <span class="string">"&lt;!--comment--&gt;&lt;node&gt;&amp;lt;&lt;/node&gt;"</span><span class="special">;</span>
-
-<span class="comment">// Parsing with default options; note that comment node is not added to the tree, and entity reference &amp;lt; is expanded
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"First node value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"], node child value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n"</span><span class="special">;</span>
-
-<span class="comment">// Parsing with additional parse_comments option; comment node is now added to the tree
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_comments</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"First node value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"], node child value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n"</span><span class="special">;</span>
-
-<span class="comment">// Parsing with additional parse_comments option and without the (default) parse_escapes option; &amp;lt; is not expanded
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_comments</span><span class="special">)</span> <span class="special">&amp;</span> <span class="special">~</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_escapes</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"First node value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"], node child value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n"</span><span class="special">;</span>
-
-<span class="comment">// Parsing with minimal option mask; comment node is not added to the tree, and &amp;lt; is not expanded
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="identifier">source</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_minimal</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"First node value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"], node child value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"node"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n"</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.encoding"></a><a class="link" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>
-</h3></div></div></div>
-<a name="xml_encoding"></a><p>
- pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little
- endian), UTF-32 (big and little endian); UCS-2 is naturally supported since
- it's a strict subset of UTF-16) and handles all encoding conversions. Most
- loading functions accept the optional parameter <code class="computeroutput"><span class="identifier">encoding</span></code>.
- This is a value of enumeration type <code class="computeroutput"><span class="identifier">xml_encoding</span></code>,
- that can have the following values:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="encoding_auto"></a><code class="literal">encoding_auto</code> means that pugixml will
- try to guess the encoding based on source XML data. The algorithm is
- a modified version of the one presented in Appendix F.1 of XML recommendation;
- it tries to match the first few bytes of input data with the following
- patterns in strict order: <br><br>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
-<li class="listitem">
- If first four bytes match UTF-32 BOM (Byte Order Mark), encoding
- is assumed to be UTF-32 with the endianness equal to that of BOM;
- </li>
-<li class="listitem">
- If first two bytes match UTF-16 BOM, encoding is assumed to be
- UTF-16 with the endianness equal to that of BOM;
- </li>
-<li class="listitem">
- If first three bytes match UTF-8 BOM, encoding is assumed to be
- UTF-8;
- </li>
-<li class="listitem">
- If first four bytes match UTF-32 representation of <code class="literal">&lt;</code>,
- encoding is assumed to be UTF-32 with the corresponding endianness;
- </li>
-<li class="listitem">
- If first four bytes match UTF-16 representation of <code class="literal">&lt;?</code>,
- encoding is assumed to be UTF-16 with the corresponding endianness;
- </li>
-<li class="listitem">
- If first two bytes match UTF-16 representation of <code class="literal">&lt;</code>,
- encoding is assumed to be UTF-16 with the corresponding endianness
- (this guess may yield incorrect result, but it's better than UTF-8);
- </li>
-<li class="listitem">
- Otherwise encoding is assumed to be UTF-8. <br><br>
-
- </li>
-</ul></div>
- </li>
-<li class="listitem">
- <a name="encoding_utf8"></a><code class="literal">encoding_utf8</code> corresponds to UTF-8 encoding
- as defined in the Unicode standard; UTF-8 sequences with length equal
- to 5 or 6 are not standard and are rejected.
- </li>
-<li class="listitem">
- <a name="encoding_utf16_le"></a><code class="literal">encoding_utf16_le</code> corresponds to
- little-endian UTF-16 encoding as defined in the Unicode standard; surrogate
- pairs are supported.
- </li>
-<li class="listitem">
- <a name="encoding_utf16_be"></a><code class="literal">encoding_utf16_be</code> corresponds to
- big-endian UTF-16 encoding as defined in the Unicode standard; surrogate
- pairs are supported.
- </li>
-<li class="listitem">
- <a name="encoding_utf16"></a><code class="literal">encoding_utf16</code> corresponds to UTF-16
- encoding as defined in the Unicode standard; the endianness is assumed
- to be that of the target platform.
- </li>
-<li class="listitem">
- <a name="encoding_utf32_le"></a><code class="literal">encoding_utf32_le</code> corresponds to
- little-endian UTF-32 encoding as defined in the Unicode standard.
- </li>
-<li class="listitem">
- <a name="encoding_utf32_be"></a><code class="literal">encoding_utf32_be</code> corresponds to
- big-endian UTF-32 encoding as defined in the Unicode standard.
- </li>
-<li class="listitem">
- <a name="encoding_utf32"></a><code class="literal">encoding_utf32</code> corresponds to UTF-32
- encoding as defined in the Unicode standard; the endianness is assumed
- to be that of the target platform.
- </li>
-<li class="listitem">
- <a name="encoding_wchar"></a><code class="literal">encoding_wchar</code> corresponds to the encoding
- of <code class="computeroutput"><span class="keyword">wchar_t</span></code> type; it has
- the same meaning as either <code class="computeroutput"><span class="identifier">encoding_utf16</span></code>
- or <code class="computeroutput"><span class="identifier">encoding_utf32</span></code>, depending
- on <code class="computeroutput"><span class="keyword">wchar_t</span></code> size.
- </li>
-<li class="listitem">
- <a name="encoding_latin1"></a><code class="literal">encoding_latin1</code> corresponds to ISO-8859-1
- encoding (also known as Latin-1).
- </li>
-</ul></div>
-<p>
- The algorithm used for <code class="computeroutput"><span class="identifier">encoding_auto</span></code>
- correctly detects any supported Unicode encoding for all well-formed XML
- documents (since they start with document declaration) and for all other
- XML documents that start with <code class="literal">&lt;</code>; if your XML document
- does not start with <code class="literal">&lt;</code> and has encoding that is different
- from UTF-8, use the specific encoding.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- The current behavior for Unicode conversion is to skip all invalid UTF
- sequences during conversion. This behavior should not be relied upon; moreover,
- in case no encoding conversion is performed, the invalid sequences are
- not removed, so you'll get them as is in node/attribute contents.
- </p></td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.loading.w3c"></a><a class="link" href="loading.html#manual.loading.w3c" title="Conformance to W3C specification"> Conformance to W3C specification</a>
-</h3></div></div></div>
-<p>
- pugixml is not fully W3C conformant - it can load any valid XML document,
- but does not perform some well-formedness checks. While considerable effort
- is made to reject invalid XML documents, some validation is not performed
- because of performance reasons.
- </p>
-<p>
- There is only one non-conformant behavior when dealing with valid XML documents:
- pugixml does not use information supplied in document type declaration for
- parsing. This means that entities declared in DOCTYPE are not expanded, and
- all attribute/PCDATA values are always processed in a uniform way that depends
- only on parsing options.
- </p>
-<p>
- As for rejecting invalid XML documents, there are a number of incompatibilities
- with W3C specification, including:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Multiple attributes of the same node can have equal names.
- </li>
-<li class="listitem">
- All non-ASCII characters are treated in the same way as symbols of English
- alphabet, so some invalid tag names are not rejected.
- </li>
-<li class="listitem">
- Attribute values which contain <code class="literal">&lt;</code> are not rejected.
- </li>
-<li class="listitem">
- Invalid entity/character references are not rejected and are instead
- left as is.
- </li>
-<li class="listitem">
- Comment values can contain <code class="literal">--</code>.
- </li>
-<li class="listitem">
- XML data is not required to begin with document declaration; additionally,
- document declaration can appear after comments and other nodes.
- </li>
-<li class="listitem">
- Invalid document type declarations are silently ignored in some cases.
- </li>
-</ul></div>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <b>Loading</b> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="dom.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="access.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/modify.html b/docs/manual/modify.html
deleted file mode 100644
index 5e44d90..0000000
--- a/docs/manual/modify.html
+++ /dev/null
@@ -1,758 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Modifying document data</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="access.html" title="Accessing document data">
-<link rel="next" href="saving.html" title="Saving document">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <b>Modifying</b> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="access.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="saving.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.modify"></a><a class="link" href="modify.html" title="Modifying document data"> Modifying document data</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="modify.html#manual.modify.nodedata"> Setting node data</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.attrdata"> Setting attribute data</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.add"> Adding nodes/attributes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.remove"> Removing nodes/attributes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.text"> Working with text contents</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.clone"> Cloning nodes/attributes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.move"> Moving nodes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.fragments"> Assembling document from fragments</a></span></dt>
-</dl></div>
-<p>
- The document in pugixml is fully mutable: you can completely change the document
- structure and modify the data of nodes/attributes. This section provides documentation
- for the relevant functions. All functions take care of memory management and
- structural integrity themselves, so they always result in structurally valid
- tree - however, it is possible to create an invalid XML tree (for example,
- by adding two attributes with the same name or by setting attribute/node name
- to empty/invalid string). Tree modification is optimized for performance and
- for memory consumption, so if you have enough memory you can create documents
- from scratch with pugixml and later save them to file/stream instead of relying
- on error-prone manual text writing and without too much overhead.
- </p>
-<p>
- All member functions that change node/attribute data or structure are non-constant
- and thus can not be called on constant handles. However, you can easily convert
- constant handle to non-constant one by simple assignment: <code class="computeroutput"><span class="keyword">void</span>
- <span class="identifier">foo</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span>
- <span class="special">{</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">nc</span> <span class="special">=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">}</span></code>, so const-correctness
- here mainly provides additional documentation.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.nodedata"></a><a class="link" href="modify.html#manual.modify.nodedata" title="Setting node data"> Setting node data</a>
-</h3></div></div></div>
-<a name="xml_node::set_name"></a><a name="xml_node::set_value"></a><p>
- As discussed before, nodes can have name and value, both of which are strings.
- Depending on node type, name or value may be absent. <a class="link" href="dom.html#node_document">node_document</a>
- nodes do not have a name or value, <a class="link" href="dom.html#node_element">node_element</a>
- and <a class="link" href="dom.html#node_declaration">node_declaration</a> nodes always
- have a name but never have a value, <a class="link" href="dom.html#node_pcdata">node_pcdata</a>,
- <a class="link" href="dom.html#node_cdata">node_cdata</a>, <a class="link" href="dom.html#node_comment">node_comment</a>
- and <a class="link" href="dom.html#node_doctype">node_doctype</a> nodes never have a name
- but always have a value (it may be empty though), <a class="link" href="dom.html#node_pi">node_pi</a>
- nodes always have a name and a value (again, value may be empty). In order
- to set node's name or value, you can use the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- Both functions try to set the name/value to the specified string, and return
- the operation result. The operation fails if the node can not have name or
- value (for instance, when trying to call <code class="computeroutput"><span class="identifier">set_name</span></code>
- on a <a class="link" href="dom.html#node_pcdata">node_pcdata</a> node), if the node handle
- is null, or if there is insufficient memory to handle the request. The provided
- string is copied into document managed memory and can be destroyed after
- the function returns (for example, you can safely pass stack-allocated buffers
- to these functions). The name/value content is not verified, so take care
- to use only valid XML names, or the document may become malformed.
- </p>
-<p>
- There is no equivalent of <a class="link" href="access.html#xml_node::child_value">child_value</a>
- function for modifying text children of the node.
- </p>
-<p>
- This is an example of setting node name and value (<a href="../samples/modify_base.cpp" target="_top">samples/modify_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span>
-
-<span class="comment">// change node name
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"notnode"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", new node name: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// change comment text
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"useless comment"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", new comment text: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// we can't change value of the element or name of the comment
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"1"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"2"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.attrdata"></a><a class="link" href="modify.html#manual.modify.attrdata" title="Setting attribute data"> Setting attribute data</a>
-</h3></div></div></div>
-<a name="xml_attribute::set_name"></a><a name="xml_attribute::set_value"></a><p>
- All attributes have name and value, both of which are strings (value may
- be empty). You can set them with the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- Both functions try to set the name/value to the specified string, and return
- the operation result. The operation fails if the attribute handle is null,
- or if there is insufficient memory to handle the request. The provided string
- is copied into document managed memory and can be destroyed after the function
- returns (for example, you can safely pass stack-allocated buffers to these
- functions). The name/value content is not verified, so take care to use only
- valid XML names, or the document may become malformed.
- </p>
-<p>
- In addition to string functions, several functions are provided for handling
- attributes with numbers and booleans as values:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="identifier">set_value</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- The above functions convert the argument to string and then call the base
- <code class="computeroutput"><span class="identifier">set_value</span></code> function. Integers
- are converted to a decimal form, floating-point numbers are converted to
- either decimal or scientific form, depending on the number magnitude, boolean
- values are converted to either <code class="computeroutput"><span class="string">"true"</span></code>
- or <code class="computeroutput"><span class="string">"false"</span></code>.
- </p>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Number conversion functions depend on current C locale as set with <code class="computeroutput"><span class="identifier">setlocale</span></code>, so may generate unexpected
- results if the locale is different from <code class="computeroutput"><span class="string">"C"</span></code>.
- </p></td></tr>
-</table></div>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- <code class="computeroutput"><span class="identifier">set_value</span></code> overloads with
- <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>
- type are only available if your platform has reliable support for the type,
- including string conversions.
- </p></td></tr>
-</table></div>
-<a name="xml_attribute::assign"></a><p>
- For convenience, all <code class="computeroutput"><span class="identifier">set_value</span></code>
- functions have the corresponding assignment operators:
- </p>
-<pre class="programlisting"><span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">xml_attribute</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- These operators simply call the right <code class="computeroutput"><span class="identifier">set_value</span></code>
- function and return the attribute they're called on; the return value of
- <code class="computeroutput"><span class="identifier">set_value</span></code> is ignored, so
- errors are ignored.
- </p>
-<p>
- This is an example of setting attribute name and value (<a href="../samples/modify_base.cpp" target="_top">samples/modify_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"id"</span><span class="special">);</span>
-
-<span class="comment">// change attribute name/value
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"key"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"345"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", new attribute: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// we can use numbers or booleans
-</span><span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="number">1.234</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"new attribute value: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// we can also use assignment operators for more concise code
-</span><span class="identifier">attr</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"final attribute value: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.add"></a><a class="link" href="modify.html#manual.modify.add" title="Adding nodes/attributes"> Adding nodes/attributes</a>
-</h3></div></div></div>
-<a name="xml_node::prepend_attribute"></a><a name="xml_node::append_attribute"></a><a name="xml_node::insert_attribute_after"></a><a name="xml_node::insert_attribute_before"></a><a name="xml_node::prepend_child"></a><a name="xml_node::append_child"></a><a name="xml_node::insert_child_after"></a><a name="xml_node::insert_child_before"></a><p>
- Nodes and attributes do not exist without a document tree, so you can't create
- them without adding them to some document. A node or attribute can be created
- at the end of node/attribute list or before/after some other node:
- </p>
-<pre class="programlisting"><span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_attribute_after</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_attribute_before</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span>
-
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_child</span><span class="special">(</span><span class="identifier">xml_node_type</span> <span class="identifier">type</span> <span class="special">=</span> <span class="identifier">node_element</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_child</span><span class="special">(</span><span class="identifier">xml_node_type</span> <span class="identifier">type</span> <span class="special">=</span> <span class="identifier">node_element</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_child_after</span><span class="special">(</span><span class="identifier">xml_node_type</span> <span class="identifier">type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="identifier">xml_node_type</span> <span class="identifier">type</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_child</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_child</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_child_after</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">append_attribute</span></code> and <code class="computeroutput"><span class="identifier">append_child</span></code> create a new node/attribute
- at the end of the corresponding list of the node the method is called on;
- <code class="computeroutput"><span class="identifier">prepend_attribute</span></code> and <code class="computeroutput"><span class="identifier">prepend_child</span></code> create a new node/attribute
- at the beginning of the list; <code class="computeroutput"><span class="identifier">insert_attribute_after</span></code>,
- <code class="computeroutput"><span class="identifier">insert_attribute_before</span></code>,
- <code class="computeroutput"><span class="identifier">insert_child_after</span></code> and <code class="computeroutput"><span class="identifier">insert_attribute_before</span></code> add the node/attribute
- before or after the specified node/attribute.
- </p>
-<p>
- Attribute functions create an attribute with the specified name; you can
- specify the empty name and change the name later if you want to. Node functions
- with the <code class="computeroutput"><span class="identifier">type</span></code> argument create
- the node with the specified type; since node type can't be changed, you have
- to know the desired type beforehand. Also note that not all types can be
- added as children; see below for clarification. Node functions with the
- <code class="computeroutput"><span class="identifier">name</span></code> argument create the
- element node (<a class="link" href="dom.html#node_element">node_element</a>) with the
- specified name.
- </p>
-<p>
- All functions return the handle to the created object on success, and null
- handle on failure. There are several reasons for failure:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Adding fails if the target node is null;
- </li>
-<li class="listitem">
- Only <a class="link" href="dom.html#node_element">node_element</a> nodes can contain
- attributes, so attribute adding fails if node is not an element;
- </li>
-<li class="listitem">
- Only <a class="link" href="dom.html#node_document">node_document</a> and <a class="link" href="dom.html#node_element">node_element</a>
- nodes can contain children, so child node adding fails if the target
- node is not an element or a document;
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_document">node_document</a> and <a class="link" href="dom.html#node_null">node_null</a>
- nodes can not be inserted as children, so passing <a class="link" href="dom.html#node_document">node_document</a>
- or <a class="link" href="dom.html#node_null">node_null</a> value as <code class="computeroutput"><span class="identifier">type</span></code> results in operation failure;
- </li>
-<li class="listitem">
- <a class="link" href="dom.html#node_declaration">node_declaration</a> nodes can only
- be added as children of the document node; attempt to insert declaration
- node as a child of an element node fails;
- </li>
-<li class="listitem">
- Adding node/attribute results in memory allocation, which may fail;
- </li>
-<li class="listitem">
- Insertion functions fail if the specified node or attribute is null or
- is not in the target node's children/attribute list.
- </li>
-</ul></div>
-<p>
- Even if the operation fails, the document remains in consistent state, but
- the requested node/attribute is not added.
- </p>
-<div class="caution"><table border="0" summary="Caution">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../images/caution.png"></td>
-<th align="left">Caution</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- attribute() and child() functions do not add attributes or nodes to the
- tree, so code like <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"id"</span><span class="special">)</span> <span class="special">=</span> <span class="number">123</span><span class="special">;</span></code> will not do anything if <code class="computeroutput"><span class="identifier">node</span></code> does not have an attribute with
- name <code class="computeroutput"><span class="string">"id"</span></code>. Make sure
- you're operating with existing attributes/nodes by adding them if necessary.
- </p></td></tr>
-</table></div>
-<p>
- This is an example of adding new attributes/nodes to the document (<a href="../samples/modify_add.cpp" target="_top">samples/modify_add.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// add node with some name
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span>
-
-<span class="comment">// add description node with text child
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">descr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span>
-<span class="identifier">descr</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_pcdata</span><span class="special">).</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"Simple node"</span><span class="special">);</span>
-
-<span class="comment">// add param node before the description
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="string">"param"</span><span class="special">,</span> <span class="identifier">descr</span><span class="special">);</span>
-
-<span class="comment">// add attributes to param node
-</span><span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"version"</span><span class="special">;</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"value"</span><span class="special">)</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">;</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">insert_attribute_after</span><span class="special">(</span><span class="string">"type"</span><span class="special">,</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">))</span> <span class="special">=</span> <span class="string">"float"</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.remove"></a><a class="link" href="modify.html#manual.modify.remove" title="Removing nodes/attributes"> Removing nodes/attributes</a>
-</h3></div></div></div>
-<a name="xml_node::remove_attribute"></a><a name="xml_node::remove_child"></a><p>
- If you do not want your document to contain some node or attribute, you can
- remove it with one of the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">remove_child</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">);</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">remove_attribute</span></code> removes
- the attribute from the attribute list of the node, and returns the operation
- result. <code class="computeroutput"><span class="identifier">remove_child</span></code> removes
- the child node with the entire subtree (including all descendant nodes and
- attributes) from the document, and returns the operation result. Removing
- fails if one of the following is true:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- The node the function is called on is null;
- </li>
-<li class="listitem">
- The attribute/node to be removed is null;
- </li>
-<li class="listitem">
- The attribute/node to be removed is not in the node's attribute/child
- list.
- </li>
-</ul></div>
-<p>
- Removing the attribute or node invalidates all handles to the same underlying
- object, and also invalidates all iterators pointing to the same object. Removing
- node also invalidates all past-the-end iterators to its attribute or child
- node list. Be careful to ensure that all such handles and iterators either
- do not exist or are not used after the attribute/node is removed.
- </p>
-<p>
- If you want to remove the attribute or child node by its name, two additional
- helper functions are available:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">remove_child</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-</pre>
-<p>
- These functions look for the first attribute or child with the specified
- name, and then remove it, returning the result. If there is no attribute
- or child with such name, the function returns <code class="computeroutput"><span class="keyword">false</span></code>;
- if there are two nodes with the given name, only the first node is deleted.
- If you want to delete all nodes with the specified name, you can use code
- like this: <code class="computeroutput"><span class="keyword">while</span> <span class="special">(</span><span class="identifier">node</span><span class="special">.</span><span class="identifier">remove_child</span><span class="special">(</span><span class="string">"tool"</span><span class="special">))</span> <span class="special">;</span></code>.
- </p>
-<p>
- This is an example of removing attributes/nodes from the document (<a href="../samples/modify_remove.cpp" target="_top">samples/modify_remove.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// remove description node with the whole subtree
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span>
-<span class="identifier">node</span><span class="special">.</span><span class="identifier">remove_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span>
-
-<span class="comment">// remove id attribute
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"param"</span><span class="special">);</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="string">"value"</span><span class="special">);</span>
-
-<span class="comment">// we can also remove nodes/attributes by handles
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">id</span> <span class="special">=</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">);</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="identifier">id</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.text"></a><a class="link" href="modify.html#manual.modify.text" title="Working with text contents"> Working with text contents</a>
-</h3></div></div></div>
-<p>
- pugixml provides a special class, <code class="computeroutput"><span class="identifier">xml_text</span></code>,
- to work with text contents stored as a value of some node, i.e. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;&lt;</span><span class="identifier">description</span><span class="special">&gt;</span><span class="identifier">This</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">node</span><span class="special">&lt;/</span><span class="identifier">description</span><span class="special">&gt;&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>.
- Working with text objects to retrieve data is described in <a class="link" href="access.html#manual.access.text" title="Working with text contents">the
- documentation for accessing document data</a>; this section describes
- the modification interface of <code class="computeroutput"><span class="identifier">xml_text</span></code>.
- </p>
-<a name="xml_text::set"></a><p>
- Once you have an <code class="computeroutput"><span class="identifier">xml_text</span></code>
- object, you can set the text contents using the following function:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- This function tries to set the contents to the specified string, and returns
- the operation result. The operation fails if the text object was retrieved
- from a node that can not have a value and is not an element node (i.e. it
- is a <a class="link" href="dom.html#node_declaration">node_declaration</a> node), if the
- text object is empty, or if there is insufficient memory to handle the request.
- The provided string is copied into document managed memory and can be destroyed
- after the function returns (for example, you can safely pass stack-allocated
- buffers to this function). Note that if the text object was retrieved from
- an element node, this function creates the PCDATA child node if necessary
- (i.e. if the element node does not have a PCDATA/CDATA child already).
- </p>
-<a name="xml_text::set_value"></a><p>
- In addition to a string function, several functions are provided for handling
- text with numbers and booleans as contents:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- The above functions convert the argument to string and then call the base
- <code class="computeroutput"><span class="identifier">set</span></code> function. These functions
- have the same semantics as similar <code class="computeroutput"><span class="identifier">xml_attribute</span></code>
- functions. You can <a class="link" href="modify.html#xml_attribute::set_value">refer to documentation
- for the attribute functions</a> for details.
- </p>
-<a name="xml_text::assign"></a><p>
- For convenience, all <code class="computeroutput"><span class="identifier">set</span></code>
- functions have the corresponding assignment operators:
- </p>
-<pre class="programlisting"><span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">double</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">bool</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-<span class="identifier">xml_text</span><span class="special">&amp;</span> <span class="identifier">xml_text</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span><span class="keyword">unsigned</span> <span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">rhs</span><span class="special">);</span>
-</pre>
-<p>
- These operators simply call the right <code class="computeroutput"><span class="identifier">set</span></code>
- function and return the attribute they're called on; the return value of
- <code class="computeroutput"><span class="identifier">set</span></code> is ignored, so errors
- are ignored.
- </p>
-<p>
- This is an example of using <code class="computeroutput"><span class="identifier">xml_text</span></code>
- object to modify text contents (<a href="../samples/text.cpp" target="_top">samples/text.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// change project version
-</span><span class="identifier">project</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"version"</span><span class="special">).</span><span class="identifier">text</span><span class="special">()</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">;</span>
-
-<span class="comment">// add description element and set the contents
-</span><span class="comment">// note that we do not have to explicitly add the node_pcdata child
-</span><span class="identifier">project</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">).</span><span class="identifier">text</span><span class="special">().</span><span class="identifier">set</span><span class="special">(</span><span class="string">"a test project"</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.clone"></a><a class="link" href="modify.html#manual.modify.clone" title="Cloning nodes/attributes"> Cloning nodes/attributes</a>
-</h3></div></div></div>
-<a name="xml_node::prepend_copy"></a><a name="xml_node::append_copy"></a><a name="xml_node::insert_copy_after"></a><a name="xml_node::insert_copy_before"></a><p>
- With the help of previously described functions, it is possible to create
- trees with any contents and structure, including cloning the existing data.
- However since this is an often needed operation, pugixml provides built-in
- node/attribute cloning facilities. Since nodes and attributes do not exist
- without a document tree, you can't create a standalone copy - you have to
- immediately insert it somewhere in the tree. For this, you can use one of
- the following functions:
- </p>
-<pre class="programlisting"><span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_copy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_copy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_copy_after</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_copy_before</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_attribute</span><span class="special">&amp;</span> <span class="identifier">attr</span><span class="special">);</span>
-
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_copy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_copy</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_copy_after</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_copy_before</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">proto</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-</pre>
-<p>
- These functions mirror the structure of <code class="computeroutput"><span class="identifier">append_child</span></code>,
- <code class="computeroutput"><span class="identifier">prepend_child</span></code>, <code class="computeroutput"><span class="identifier">insert_child_before</span></code> and related functions
- - they take the handle to the prototype object, which is to be cloned, insert
- a new attribute/node at the appropriate place, and then copy the attribute
- data or the whole node subtree to the new object. The functions return the
- handle to the resulting duplicate object, or null handle on failure.
- </p>
-<p>
- The attribute is copied along with the name and value; the node is copied
- along with its type, name and value; additionally attribute list and all
- children are recursively cloned, resulting in the deep subtree clone. The
- prototype object can be a part of the same document, or a part of any other
- document.
- </p>
-<p>
- The failure conditions resemble those of <code class="computeroutput"><span class="identifier">append_child</span></code>,
- <code class="computeroutput"><span class="identifier">insert_child_before</span></code> and related
- functions, <a class="link" href="modify.html#xml_node::append_child">consult their documentation
- for more information</a>. There are additional caveats specific to cloning
- functions:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Cloning null handles results in operation failure;
- </li>
-<li class="listitem">
- Node cloning starts with insertion of the node of the same type as that
- of the prototype; for this reason, cloning functions can not be directly
- used to clone entire documents, since <a class="link" href="dom.html#node_document">node_document</a>
- is not a valid insertion type. The example below provides a workaround.
- </li>
-<li class="listitem">
- It is possible to copy a subtree as a child of some node inside this
- subtree, i.e. <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">append_copy</span><span class="special">(</span><span class="identifier">node</span><span class="special">.</span><span class="identifier">parent</span><span class="special">().</span><span class="identifier">parent</span><span class="special">());</span></code>.
- This is a valid operation, and it results in a clone of the subtree in
- the state before cloning started, i.e. no infinite recursion takes place.
- </li>
-</ul></div>
-<p>
- This is an example with one possible implementation of include tags in XML
- (<a href="../samples/include.cpp" target="_top">samples/include.cpp</a>). It illustrates
- node cloning and usage of other document modification functions:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">load_preprocess</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span><span class="special">&amp;</span> <span class="identifier">doc</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">);</span>
-
-<span class="keyword">bool</span> <span class="identifier">preprocess</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">child</span><span class="special">;</span> <span class="special">)</span>
- <span class="special">{</span>
- <span class="keyword">if</span> <span class="special">(</span><span class="identifier">child</span><span class="special">.</span><span class="identifier">type</span><span class="special">()</span> <span class="special">==</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_pi</span> <span class="special">&amp;&amp;</span> <span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">child</span><span class="special">.</span><span class="identifier">name</span><span class="special">(),</span> <span class="string">"include"</span><span class="special">)</span> <span class="special">==</span> <span class="number">0</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">include</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">;</span>
-
- <span class="comment">// load new preprocessed document (note: ideally this should handle relative paths)
-</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span> <span class="special">=</span> <span class="identifier">include</span><span class="special">.</span><span class="identifier">value</span><span class="special">();</span>
-
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
- <span class="keyword">if</span> <span class="special">(!</span><span class="identifier">load_preprocess</span><span class="special">(</span><span class="identifier">doc</span><span class="special">,</span> <span class="identifier">path</span><span class="special">))</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span>
-
- <span class="comment">// insert the comment marker above include directive
-</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_comment</span><span class="special">,</span> <span class="identifier">include</span><span class="special">).</span><span class="identifier">set_value</span><span class="special">(</span><span class="identifier">path</span><span class="special">);</span>
-
- <span class="comment">// copy the document above the include directive (this retains the original order!)
-</span> <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">ic</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">ic</span><span class="special">;</span> <span class="identifier">ic</span> <span class="special">=</span> <span class="identifier">ic</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span>
- <span class="special">{</span>
- <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_copy_before</span><span class="special">(</span><span class="identifier">ic</span><span class="special">,</span> <span class="identifier">include</span><span class="special">);</span>
- <span class="special">}</span>
-
- <span class="comment">// remove the include node and move to the next child
-</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">();</span>
-
- <span class="identifier">node</span><span class="special">.</span><span class="identifier">remove_child</span><span class="special">(</span><span class="identifier">include</span><span class="special">);</span>
- <span class="special">}</span>
- <span class="keyword">else</span>
- <span class="special">{</span>
- <span class="keyword">if</span> <span class="special">(!</span><span class="identifier">preprocess</span><span class="special">(</span><span class="identifier">child</span><span class="special">))</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span>
-
- <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">();</span>
- <span class="special">}</span>
- <span class="special">}</span>
-
- <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span>
-<span class="special">}</span>
-
-<span class="keyword">bool</span> <span class="identifier">load_preprocess</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span><span class="special">&amp;</span> <span class="identifier">doc</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="identifier">path</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_default</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">parse_pi</span><span class="special">);</span> <span class="comment">// for &lt;?include?&gt;
-</span>
- <span class="keyword">return</span> <span class="identifier">result</span> <span class="special">?</span> <span class="identifier">preprocess</span><span class="special">(</span><span class="identifier">doc</span><span class="special">)</span> <span class="special">:</span> <span class="keyword">false</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.move"></a><a class="link" href="modify.html#manual.modify.move" title="Moving nodes"> Moving nodes</a>
-</h3></div></div></div>
-<a name="xml_node::prepend_move"></a><a name="xml_node::append_move"></a><a name="xml_node::insert_move_after"></a><a name="xml_node::insert_move_before"></a><p>
- Sometimes instead of cloning a node you need to move an existing node to
- a different position in a tree. This can be accomplished by copying the node
- and removing the original; however, this is expensive since it results in
- a lot of extra operations. For moving nodes within the same document tree,
- you can use of the following functions instead:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_move</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">moved</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">prepend_move</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">moved</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_move_after</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">moved</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-<span class="identifier">xml_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">insert_move_before</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">moved</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">);</span>
-</pre>
-<p>
- These functions mirror the structure of <code class="computeroutput"><span class="identifier">append_copy</span></code>,
- <code class="computeroutput"><span class="identifier">prepend_copy</span></code>, <code class="computeroutput"><span class="identifier">insert_copy_before</span></code> and <code class="computeroutput"><span class="identifier">insert_copy_after</span></code>
- - they take the handle to the moved object and move it to the appropriate
- place with all attributes and/or child nodes. The functions return the handle
- to the resulting object (which is the same as the moved object), or null
- handle on failure.
- </p>
-<p>
- The failure conditions resemble those of <code class="computeroutput"><span class="identifier">append_child</span></code>,
- <code class="computeroutput"><span class="identifier">insert_child_before</span></code> and related
- functions, <a class="link" href="modify.html#xml_node::append_child">consult their documentation
- for more information</a>. There are additional caveats specific to moving
- functions:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Moving null handles results in operation failure;
- </li>
-<li class="listitem">
- Moving is only possible for nodes that belong to the same document; attempting
- to move nodes between documents will fail.
- </li>
-<li class="listitem">
- <code class="computeroutput"><span class="identifier">insert_move_after</span></code> and
- <code class="computeroutput"><span class="identifier">insert_move_before</span></code> functions
- fail if the moved node is the same as the <code class="computeroutput"><span class="identifier">node</span></code>
- argument (this operation would be a no-op otherwise).
- </li>
-<li class="listitem">
- It is impossible to move a subtree to a child of some node inside this
- subtree, i.e. <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">append_move</span><span class="special">(</span><span class="identifier">node</span><span class="special">.</span><span class="identifier">parent</span><span class="special">().</span><span class="identifier">parent</span><span class="special">());</span></code>
- will fail.
- </li>
-</ul></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.modify.fragments"></a><a class="link" href="modify.html#manual.modify.fragments" title="Assembling document from fragments"> Assembling document from fragments</a>
-</h3></div></div></div>
-<a name="xml_node::append_buffer"></a><p>
- pugixml provides several ways to assemble an XML document from other XML
- documents. Assuming there is a set of document fragments, represented as
- in-memory buffers, the implementation choices are as follows:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Use a temporary document to parse the data from a string, then clone
- the nodes to a destination node. For example:
- </li></ul></div>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">append_fragment</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">target</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
- <span class="keyword">if</span> <span class="special">(!</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">))</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">child</span><span class="special">;</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span>
- <span class="identifier">target</span><span class="special">.</span><span class="identifier">append_copy</span><span class="special">(</span><span class="identifier">child</span><span class="special">);</span>
-<span class="special">}</span>
-</pre>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Cache the parsing step - instead of keeping in-memory buffers, keep document
- objects that already contain the parsed fragment:
- </li></ul></div>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">append_fragment</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">target</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span><span class="special">&amp;</span> <span class="identifier">cached_fragment</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">cached_fragment</span><span class="special">.</span><span class="identifier">first_child</span><span class="special">();</span> <span class="identifier">child</span><span class="special">;</span> <span class="identifier">child</span> <span class="special">=</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span>
- <span class="identifier">target</span><span class="special">.</span><span class="identifier">append_copy</span><span class="special">(</span><span class="identifier">child</span><span class="special">);</span>
-<span class="special">}</span>
-</pre>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- Use xml_node::append_buffer directly:
- </li></ul></div>
-<pre class="programlisting"><span class="identifier">xml_parse_result</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">append_buffer</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">contents</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">options</span> <span class="special">=</span> <span class="identifier">parse_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">);</span>
-</pre>
-<p>
- The first method is more convenient, but slower than the other two. The relative
- performance of <code class="computeroutput"><span class="identifier">append_copy</span></code>
- and <code class="computeroutput"><span class="identifier">append_buffer</span></code> depends
- on the buffer format - usually <code class="computeroutput"><span class="identifier">append_buffer</span></code>
- is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending
- on <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>). At
- the same time it might be less efficient in terms of memory usage - the implementation
- makes a copy of the provided buffer, and the copy has the same lifetime as
- the document - the memory used by that copy will be reclaimed after the document
- is destroyed, but no sooner. Even deleting all nodes in the document, including
- the appended ones, won't reclaim the memory.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">append_buffer</span></code> behaves in
- the same way as <a class="link" href="loading.html#xml_document::load_buffer">xml_document::load_buffer</a>
- - the input buffer is a byte buffer, with size in bytes; the buffer is not
- modified and can be freed after the function returns.
- </p>
-<a name="status_append_invalid_root"></a><p>
- Since <code class="computeroutput"><span class="identifier">append_buffer</span></code> needs
- to append child nodes to the current node, it only works if the current node
- is either document or element node. Calling <code class="computeroutput"><span class="identifier">append_buffer</span></code>
- on a node with any other type results in an error with <code class="computeroutput"><span class="identifier">status_append_invalid_root</span></code>
- status.
- </p>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <b>Modifying</b> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="access.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="saving.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/saving.html b/docs/manual/saving.html
deleted file mode 100644
index 7157d84..0000000
--- a/docs/manual/saving.html
+++ /dev/null
@@ -1,543 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Saving document</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="modify.html" title="Modifying document data">
-<link rel="next" href="xpath.html" title="XPath">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <b>Saving</b> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="modify.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="xpath.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.saving"></a><a class="link" href="saving.html" title="Saving document"> Saving document</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="saving.html#manual.saving.file"> Saving document to a file</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.stream"> Saving document to C++ IOstreams</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.writer"> Saving document via writer interface</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.subtree"> Saving a single subtree</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.options"> Output options</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.encoding"> Encodings</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.declaration"> Customizing document declaration</a></span></dt>
-</dl></div>
-<p>
- Often after creating a new document or loading the existing one and processing
- it, it is necessary to save the result back to file. Also it is occasionally
- useful to output the whole document or a subtree to some stream; use cases
- include debug printing, serialization via network or other text-oriented medium,
- etc. pugixml provides several functions to output any subtree of the document
- to a file, stream or another generic transport interface; these functions allow
- to customize the output format (see <a class="xref" href="saving.html#manual.saving.options" title="Output options"> Output options</a>), and also perform
- necessary encoding conversions (see <a class="xref" href="saving.html#manual.saving.encoding" title="Encodings"> Encodings</a>). This section documents
- the relevant functionality.
- </p>
-<p>
- Before writing to the destination the node/attribute data is properly formatted
- according to the node type; all special XML symbols, such as &lt; and &amp;,
- are properly escaped (unless <a class="link" href="saving.html#format_no_escapes">format_no_escapes</a>
- flag is set). In order to guard against forgotten node/attribute names, empty
- node/attribute names are printed as <code class="computeroutput"><span class="string">":anonymous"</span></code>.
- For well-formed output, make sure all node and attribute names are set to meaningful
- values.
- </p>
-<p>
- CDATA sections with values that contain <code class="computeroutput"><span class="string">"]]&gt;"</span></code>
- are split into several sections as follows: section with value <code class="computeroutput"><span class="string">"pre]]&gt;post"</span></code> is written as <code class="computeroutput"><span class="special">&lt;![</span><span class="identifier">CDATA</span><span class="special">[</span><span class="identifier">pre</span><span class="special">]]]]&gt;&lt;![</span><span class="identifier">CDATA</span><span class="special">[&gt;</span><span class="identifier">post</span><span class="special">]]&gt;</span></code>.
- While this alters the structure of the document (if you load the document after
- saving it, there will be two CDATA sections instead of one), this is the only
- way to escape CDATA contents.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.file"></a><a class="link" href="saving.html#manual.saving.file" title="Saving document to a file"> Saving document to a file</a>
-</h3></div></div></div>
-<a name="xml_document::save_file"></a><a name="xml_document::save_file_wide"></a><p>
- If you want to save the whole document to a file, you can use one of the
- following functions:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save_file</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">wchar_t</span><span class="special">*</span> <span class="identifier">path</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- These functions accept file path as its first argument, and also three optional
- arguments, which specify indentation and other output options (see <a class="xref" href="saving.html#manual.saving.options" title="Output options"> Output options</a>)
- and output data encoding (see <a class="xref" href="saving.html#manual.saving.encoding" title="Encodings"> Encodings</a>). The path has the target
- operating system format, so it can be a relative or absolute one, it should
- have the delimiters of the target system, it should have the exact case if
- the target file system is case-sensitive, etc.
- </p>
-<p>
- File path is passed to the system file opening function as is in case of
- the first function (which accepts <code class="computeroutput"><span class="keyword">const</span>
- <span class="keyword">char</span><span class="special">*</span> <span class="identifier">path</span></code>); the second function either uses
- a special file opening function if it is provided by the runtime library
- or converts the path to UTF-8 and uses the system file opening function.
- </p>
-<a name="xml_writer_file"></a><p>
- <code class="computeroutput"><span class="identifier">save_file</span></code> opens the target
- file for writing, outputs the requested header (by default a document declaration
- is output, unless the document already has one), and then saves the document
- contents. If the file could not be opened, the function returns <code class="computeroutput"><span class="keyword">false</span></code>. Calling <code class="computeroutput"><span class="identifier">save_file</span></code>
- is equivalent to creating an <code class="computeroutput"><span class="identifier">xml_writer_file</span></code>
- object with <code class="computeroutput"><span class="identifier">FILE</span><span class="special">*</span></code>
- handle as the only constructor argument and then calling <code class="computeroutput"><span class="identifier">save</span></code>;
- see <a class="xref" href="saving.html#manual.saving.writer" title="Saving document via writer interface"> Saving document via writer interface</a> for writer interface details.
- </p>
-<p>
- This is a simple example of saving XML document to file (<a href="../samples/save_file.cpp" target="_top">samples/save_file.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// save document to file
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Saving result: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">save_file</span><span class="special">(</span><span class="string">"save_file_output.xml"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.stream"></a><a class="link" href="saving.html#manual.saving.stream" title="Saving document to C++ IOstreams"> Saving document to C++ IOstreams</a>
-</h3></div></div></div>
-<a name="xml_document::save_stream"></a><p>
- To enhance interoperability pugixml provides functions for saving document
- to any object which implements C++ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span></code>
- interface. This allows you to save documents to any standard C++ stream (i.e.
- file stream) or any third-party compliant implementation (i.e. Boost Iostreams).
- Most notably, this allows for easy debug output, since you can use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span></code>
- stream as saving target. There are two functions, one works with narrow character
- streams, another handles wide character ones:
- </p>
-<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">void</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wostream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">save</span></code> with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span></code>
- argument saves the document to the stream in the same way as <code class="computeroutput"><span class="identifier">save_file</span></code> (i.e. with requested header and
- with encoding conversions). On the other hand, <code class="computeroutput"><span class="identifier">save</span></code>
- with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstream</span></code> argument saves the document to
- the wide stream with <a class="link" href="loading.html#encoding_wchar">encoding_wchar</a>
- encoding. Because of this, using <code class="computeroutput"><span class="identifier">save</span></code>
- with wide character streams requires careful (usually platform-specific)
- stream setup (i.e. using the <code class="computeroutput"><span class="identifier">imbue</span></code>
- function). Generally use of wide streams is discouraged, however it provides
- you with the ability to save documents to non-Unicode encodings, i.e. you
- can save Shift-JIS encoded data if you set the correct locale.
- </p>
-<a name="xml_writer_stream"></a><p>
- Calling <code class="computeroutput"><span class="identifier">save</span></code> with stream
- target is equivalent to creating an <code class="computeroutput"><span class="identifier">xml_writer_stream</span></code>
- object with stream as the only constructor argument and then calling <code class="computeroutput"><span class="identifier">save</span></code>; see <a class="xref" href="saving.html#manual.saving.writer" title="Saving document via writer interface"> Saving document via writer interface</a> for writer
- interface details.
- </p>
-<p>
- This is a simple example of saving XML document to standard output (<a href="../samples/save_stream.cpp" target="_top">samples/save_stream.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// save document to standard output
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Document:\n"</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.writer"></a><a class="link" href="saving.html#manual.saving.writer" title="Saving document via writer interface"> Saving document via writer interface</a>
-</h3></div></div></div>
-<a name="xml_document::save"></a><a name="xml_writer"></a><a name="xml_writer::write"></a><p>
- All of the above saving functions are implemented in terms of writer interface.
- This is a simple interface with a single function, which is called several
- times during output process with chunks of document data as input:
- </p>
-<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">xml_writer</span>
-<span class="special">{</span>
-<span class="keyword">public</span><span class="special">:</span>
- <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="identifier">write</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">data</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">};</span>
-
-<span class="keyword">void</span> <span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">xml_writer</span><span class="special">&amp;</span> <span class="identifier">writer</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- In order to output the document via some custom transport, for example sockets,
- you should create an object which implements <code class="computeroutput"><span class="identifier">xml_writer</span></code>
- interface and pass it to <code class="computeroutput"><span class="identifier">save</span></code>
- function. <code class="computeroutput"><span class="identifier">xml_writer</span><span class="special">::</span><span class="identifier">write</span></code> function is called with a buffer
- as an input, where <code class="computeroutput"><span class="identifier">data</span></code> points
- to buffer start, and <code class="computeroutput"><span class="identifier">size</span></code>
- is equal to the buffer size in bytes. <code class="computeroutput"><span class="identifier">write</span></code>
- implementation must write the buffer to the transport; it can not save the
- passed buffer pointer, as the buffer contents will change after <code class="computeroutput"><span class="identifier">write</span></code> returns. The buffer contains the
- chunk of document data in the desired encoding.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">write</span></code> function is called
- with relatively large blocks (size is usually several kilobytes, except for
- the last block that may be small), so there is often no need for additional
- buffering in the implementation.
- </p>
-<p>
- This is a simple example of custom writer for saving document data to STL
- string (<a href="../samples/save_custom_writer.cpp" target="_top">samples/save_custom_writer.cpp</a>);
- read the sample code for more complex examples:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xml_string_writer</span><span class="special">:</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_writer</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">result</span><span class="special">;</span>
-
- <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="identifier">write</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">data</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="identifier">result</span> <span class="special">+=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;(</span><span class="identifier">data</span><span class="special">),</span> <span class="identifier">size</span><span class="special">);</span>
- <span class="special">}</span>
-<span class="special">};</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.subtree"></a><a class="link" href="saving.html#manual.saving.subtree" title="Saving a single subtree"> Saving a single subtree</a>
-</h3></div></div></div>
-<a name="xml_node::print"></a><a name="xml_node::print_stream"></a><p>
- While the previously described functions save the whole document to the destination,
- it is easy to save a single subtree. The following functions are provided:
- </p>
-<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&amp;</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">depth</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">void</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">wostream</span><span class="special">&amp;</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">depth</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">void</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">xml_writer</span><span class="special">&amp;</span> <span class="identifier">writer</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">indent</span> <span class="special">=</span> <span class="string">"\t"</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">flags</span> <span class="special">=</span> <span class="identifier">format_default</span><span class="special">,</span> <span class="identifier">xml_encoding</span> <span class="identifier">encoding</span> <span class="special">=</span> <span class="identifier">encoding_auto</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">depth</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- These functions have the same arguments with the same meaning as the corresponding
- <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span></code> functions, and allow you to save the
- subtree to either a C++ IOstream or to any object that implements <code class="computeroutput"><span class="identifier">xml_writer</span></code> interface.
- </p>
-<p>
- Saving a subtree differs from saving the whole document: the process behaves
- as if <a class="link" href="saving.html#format_write_bom">format_write_bom</a> is off, and
- <a class="link" href="saving.html#format_no_declaration">format_no_declaration</a> is on,
- even if actual values of the flags are different. This means that BOM is
- not written to the destination, and document declaration is only written
- if it is the node itself or is one of node's children. Note that this also
- holds if you're saving a document; this example (<a href="../samples/save_subtree.cpp" target="_top">samples/save_subtree.cpp</a>)
- illustrates the difference:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// get a test document
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="string">"&lt;foo bar='baz'&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;"</span><span class="special">);</span>
-
-<span class="comment">// print document to standard output (prints &lt;?xml version="1.0"?&gt;&lt;foo bar="baz"&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;)
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// print document to standard output as a regular node (prints &lt;foo bar="baz"&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;)
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// print a subtree to standard output (prints &lt;call&gt;hey&lt;/call&gt;)
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"foo"</span><span class="special">).</span><span class="identifier">child</span><span class="special">(</span><span class="string">"call"</span><span class="special">).</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">""</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.options"></a><a class="link" href="saving.html#manual.saving.options" title="Output options"> Output options</a>
-</h3></div></div></div>
-<p>
- All saving functions accept the optional parameter <code class="computeroutput"><span class="identifier">flags</span></code>.
- This is a bitmask that customizes the output format; you can select the way
- the document nodes are printed and select the needed additional information
- that is output before the document contents.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- You should use the usual bitwise arithmetics to manipulate the bitmask:
- to enable a flag, use <code class="computeroutput"><span class="identifier">mask</span> <span class="special">|</span> <span class="identifier">flag</span></code>;
- to disable a flag, use <code class="computeroutput"><span class="identifier">mask</span> <span class="special">&amp;</span> <span class="special">~</span><span class="identifier">flag</span></code>.
- </p></td></tr>
-</table></div>
-<p>
- These flags control the resulting tree contents:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="format_indent"></a><code class="literal">format_indent</code> determines if all nodes
- should be indented with the indentation string (this is an additional
- parameter for all saving functions, and is <code class="computeroutput"><span class="string">"\t"</span></code>
- by default). If this flag is on, before every node the indentation string
- is output several times, where the amount of indentation depends on the
- node's depth relative to the output subtree. This flag has no effect
- if <a class="link" href="saving.html#format_raw">format_raw</a> is enabled. This flag
- is <span class="bold"><strong>on</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="format_raw"></a><code class="literal">format_raw</code> switches between formatted and
- raw output. If this flag is on, the nodes are not indented in any way,
- and also no newlines that are not part of document text are printed.
- Raw mode can be used for serialization where the result is not intended
- to be read by humans; also it can be useful if the document was parsed
- with <a class="link" href="loading.html#parse_ws_pcdata">parse_ws_pcdata</a> flag, to
- preserve the original document formatting as much as possible. This flag
- is <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="format_no_escapes"></a><code class="literal">format_no_escapes</code> disables output
- escaping for attribute values and PCDATA contents. If this flag is off,
- special symbols (', &amp;, &lt;, &gt;) and all non-printable characters
- (those with codepoint values less than 32) are converted to XML escape
- sequences (i.e. &amp;amp;) during output. If this flag is on, no text
- processing is performed; therefore, output XML can be malformed if output
- contents contains invalid symbols (i.e. having a stray &lt; in the PCDATA
- will make the output malformed). This flag is <span class="bold"><strong>off</strong></span>
- by default.
- </li>
-</ul></div>
-<p>
- These flags control the additional output information:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- <a name="format_no_declaration"></a><code class="literal">format_no_declaration</code> disables
- default node declaration output. By default, if the document is saved
- via <code class="computeroutput"><span class="identifier">save</span></code> or <code class="computeroutput"><span class="identifier">save_file</span></code> function, and it does not
- have any document declaration, a default declaration is output before
- the document contents. Enabling this flag disables this declaration.
- This flag has no effect in <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span></code>
- functions: they never output the default declaration. This flag is <span class="bold"><strong>off</strong></span> by default. <br><br>
-
- </li>
-<li class="listitem">
- <a name="format_write_bom"></a><code class="literal">format_write_bom</code> enables Byte Order
- Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8
- encodings the resulting document's encoding may not be recognized by
- some parsers and text editors, if they do not implement sophisticated
- encoding detection. Enabling this flag adds an encoding-specific BOM
- to the output. This flag has no effect in <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span></code>
- functions: they never output the BOM. This flag is <span class="bold"><strong>off</strong></span>
- by default.
- </li>
-<li class="listitem">
- <a name="format_save_file_text"></a><code class="literal">format_save_file_text</code> changes
- the file mode when using <code class="computeroutput"><span class="identifier">save_file</span></code>
- function. By default, file is opened in binary mode, which means that
- the output file will contain platform-independent newline \n (ASCII 10).
- If this flag is on, file is opened in text mode, which on some systems
- changes the newline format (i.e. on Windows you can use this flag to
- output XML documents with \r\n (ASCII 13 10) newlines. This flag is
- <span class="bold"><strong>off</strong></span> by default.
- </li>
-</ul></div>
-<p>
- Additionally, there is one predefined option mask:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- <a name="format_default"></a><code class="literal">format_default</code> is the default set of
- flags, i.e. it has all options set to their default values. It sets formatted
- output with indentation, without BOM and with default node declaration,
- if necessary.
- </li></ul></div>
-<p>
- This is an example that shows the outputs of different output options (<a href="../samples/save_options.cpp" target="_top">samples/save_options.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// get a test document
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="string">"&lt;foo bar='baz'&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;"</span><span class="special">);</span>
-
-<span class="comment">// default options; prints
-</span><span class="comment">// &lt;?xml version="1.0"?&gt;
-</span><span class="comment">// &lt;foo bar="baz"&gt;
-</span><span class="comment">// &lt;call&gt;hey&lt;/call&gt;
-</span><span class="comment">// &lt;/foo&gt;
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// default options with custom indentation string; prints
-</span><span class="comment">// &lt;?xml version="1.0"?&gt;
-</span><span class="comment">// &lt;foo bar="baz"&gt;
-</span><span class="comment">// --&lt;call&gt;hey&lt;/call&gt;
-</span><span class="comment">// &lt;/foo&gt;
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"--"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// default options without indentation; prints
-</span><span class="comment">// &lt;?xml version="1.0"?&gt;
-</span><span class="comment">// &lt;foo bar="baz"&gt;
-</span><span class="comment">// &lt;call&gt;hey&lt;/call&gt;
-</span><span class="comment">// &lt;/foo&gt;
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_default</span> <span class="special">&amp;</span> <span class="special">~</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_indent</span><span class="special">);</span> <span class="comment">// can also pass "" instead of indentation string for the same effect
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// raw output; prints
-</span><span class="comment">// &lt;?xml version="1.0"?&gt;&lt;foo bar="baz"&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// raw output without declaration; prints
-</span><span class="comment">// &lt;foo bar="baz"&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\t"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_raw</span> <span class="special">|</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">format_no_declaration</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.encoding"></a><a class="link" href="saving.html#manual.saving.encoding" title="Encodings"> Encodings</a>
-</h3></div></div></div>
-<p>
- pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little
- endian), UTF-32 (big and little endian); UCS-2 is naturally supported since
- it's a strict subset of UTF-16) and handles all encoding conversions during
- output. The output encoding is set via the <code class="computeroutput"><span class="identifier">encoding</span></code>
- parameter of saving functions, which is of type <code class="computeroutput"><span class="identifier">xml_encoding</span></code>.
- The possible values for the encoding are documented in <a class="xref" href="loading.html#manual.loading.encoding" title="Encodings"> Encodings</a>;
- the only flag that has a different meaning is <code class="computeroutput"><span class="identifier">encoding_auto</span></code>.
- </p>
-<p>
- While all other flags set the exact encoding, <code class="computeroutput"><span class="identifier">encoding_auto</span></code>
- is meant for automatic encoding detection. The automatic detection does not
- make sense for output encoding, since there is usually nothing to infer the
- actual encoding from, so here <code class="computeroutput"><span class="identifier">encoding_auto</span></code>
- means UTF-8 encoding, which is the most popular encoding for XML data storage.
- This is also the default value of output encoding; specify another value
- if you do not want UTF-8 encoded output.
- </p>
-<p>
- Also note that wide stream saving functions do not have <code class="computeroutput"><span class="identifier">encoding</span></code>
- argument and always assume <a class="link" href="loading.html#encoding_wchar">encoding_wchar</a>
- encoding.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- The current behavior for Unicode conversion is to skip all invalid UTF
- sequences during conversion. This behavior should not be relied upon; if
- your node/attribute names do not contain any valid UTF sequences, they
- may be output as if they are empty, which will result in malformed XML
- document.
- </p></td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.saving.declaration"></a><a class="link" href="saving.html#manual.saving.declaration" title="Customizing document declaration"> Customizing document declaration</a>
-</h3></div></div></div>
-<p>
- When you are saving the document using <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save_file</span><span class="special">()</span></code>, a default XML document declaration is
- output, if <code class="computeroutput"><span class="identifier">format_no_declaration</span></code>
- is not specified and if the document does not have a declaration node. However,
- the default declaration is not customizable. If you want to customize the
- declaration output, you need to create the declaration node yourself.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- By default the declaration node is not added to the document during parsing.
- If you just need to preserve the original declaration node, you have to
- add the flag <a class="link" href="loading.html#parse_declaration">parse_declaration</a>
- to the parsing flags; the resulting document will contain the original
- declaration node, which will be output during saving.
- </p></td></tr>
-</table></div>
-<p>
- Declaration node is a node with type <a class="link" href="dom.html#node_declaration">node_declaration</a>;
- it behaves like an element node in that it has attributes with values (but
- it does not have child nodes). Therefore setting custom version, encoding
- or standalone declaration involves adding attributes and setting attribute
- values.
- </p>
-<p>
- This is an example that shows how to create a custom declaration node (<a href="../samples/save_declaration.cpp" target="_top">samples/save_declaration.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// get a test document
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="string">"&lt;foo bar='baz'&gt;&lt;call&gt;hey&lt;/call&gt;&lt;/foo&gt;"</span><span class="special">);</span>
-
-<span class="comment">// add a custom declaration node
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">decl</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">prepend_child</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_declaration</span><span class="special">);</span>
-<span class="identifier">decl</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"version"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"1.0"</span><span class="special">;</span>
-<span class="identifier">decl</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"encoding"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"UTF-8"</span><span class="special">;</span>
-<span class="identifier">decl</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"standalone"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"no"</span><span class="special">;</span>
-
-<span class="comment">// &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
-</span><span class="comment">// &lt;foo bar="baz"&gt;
-</span><span class="comment">// &lt;call&gt;hey&lt;/call&gt;
-</span><span class="comment">// &lt;/foo&gt;
-</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <b>Saving</b> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="modify.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="xpath.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/toc.html b/docs/manual/toc.html
deleted file mode 100644
index b36f757..0000000
--- a/docs/manual/toc.html
+++ /dev/null
@@ -1,163 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>Table of Contents</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="apiref.html" title="API Reference">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <b>Table of Contents</b>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="apiref.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.toc"></a><a class="link" href="toc.html" title="Table of Contents"> Table of Contents</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="../manual.html#manual.overview"> Overview</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="../manual.html#manual.overview.introduction"> Introduction</a></span></dt>
-<dt><span class="section"><a href="../manual.html#manual.overview.feedback"> Feedback</a></span></dt>
-<dt><span class="section"><a href="../manual.html#manual.overview.thanks"> Acknowledgments</a></span></dt>
-<dt><span class="section"><a href="../manual.html#manual.overview.license"> License</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="install.html"> Installation</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="install.html#manual.install.getting"> Getting pugixml</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="install.html#manual.install.getting.source"> Source distributions</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.getting.git"> Git repository</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.getting.subversion"> Subversion repository</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="install.html#manual.install.building"> Building pugixml</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="install.html#manual.install.building.embed"> Building pugixml as
- a part of another static library/executable</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.static"> Building pugixml as
- a standalone static library</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.shared"> Building pugixml as
- a standalone shared library</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.header"> Using pugixml in header-only
- mode</a></span></dt>
-<dt><span class="section"><a href="install.html#manual.install.building.config"> Additional configuration
- options</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="install.html#manual.install.portability"> Portability</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="dom.html"> Document object model</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="dom.html#manual.dom.tree"> Tree structure</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.cpp"> C++ interface</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.unicode"> Unicode interface</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.thread"> Thread-safety guarantees</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.exception"> Exception guarantees</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.memory"> Memory management</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="dom.html#manual.dom.memory.custom"> Custom memory allocation/deallocation
- functions</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.memory.tuning"> Memory consumption tuning</a></span></dt>
-<dt><span class="section"><a href="dom.html#manual.dom.memory.internals"> Document memory management
- internals</a></span></dt>
-</dl></dd>
-</dl></dd>
-<dt><span class="section"><a href="loading.html"> Loading document</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="loading.html#manual.loading.file"> Loading document from file</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.memory"> Loading document from memory</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.stream"> Loading document from C++ IOstreams</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.errors"> Handling parsing errors</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.options"> Parsing options</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.encoding"> Encodings</a></span></dt>
-<dt><span class="section"><a href="loading.html#manual.loading.w3c"> Conformance to W3C specification</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="access.html"> Accessing document data</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="access.html#manual.access.basic"> Basic traversal functions</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.nodedata"> Getting node data</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.attrdata"> Getting attribute data</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.contents"> Contents-based traversal functions</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.rangefor"> Range-based for-loop support</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.iterators"> Traversing node/attribute lists
- via iterators</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.walker"> Recursive traversal with xml_tree_walker</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.predicate"> Searching for nodes/attributes
- with predicates</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.text"> Working with text contents</a></span></dt>
-<dt><span class="section"><a href="access.html#manual.access.misc"> Miscellaneous functions</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="modify.html"> Modifying document data</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="modify.html#manual.modify.nodedata"> Setting node data</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.attrdata"> Setting attribute data</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.add"> Adding nodes/attributes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.remove"> Removing nodes/attributes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.text"> Working with text contents</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.clone"> Cloning nodes/attributes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.move"> Moving nodes</a></span></dt>
-<dt><span class="section"><a href="modify.html#manual.modify.fragments"> Assembling document from fragments</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="saving.html"> Saving document</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="saving.html#manual.saving.file"> Saving document to a file</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.stream"> Saving document to C++ IOstreams</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.writer"> Saving document via writer interface</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.subtree"> Saving a single subtree</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.options"> Output options</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.encoding"> Encodings</a></span></dt>
-<dt><span class="section"><a href="saving.html#manual.saving.declaration"> Customizing document declaration</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="xpath.html"> XPath</a></span></dt>
-<dd><dl>
-<dt><span class="section"><a href="xpath.html#manual.xpath.types"> XPath types</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.select"> Selecting nodes via XPath expression</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.query"> Using query objects</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.variables"> Using variables</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.errors"> Error handling</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.w3c"> Conformance to W3C specification</a></span></dt>
-</dl></dd>
-<dt><span class="section"><a href="changes.html"> Changelog</a></span></dt>
-<dt><span class="section"><a href="apiref.html"> API Reference</a></span></dt>
-<dt><span class="section"><a href="toc.html"> Table of Contents</a></span></dt>
-</dl></div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <a href="xpath.html">XPath</a> |
- <a href="apiref.html">API Reference</a> |
- <b>Table of Contents</b>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="apiref.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/manual/xpath.html b/docs/manual/xpath.html
deleted file mode 100644
index 7194283..0000000
--- a/docs/manual/xpath.html
+++ /dev/null
@@ -1,749 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>XPath</title>
-<link rel="stylesheet" href="../pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="../manual.html" title="pugixml 1.5">
-<link rel="up" href="../manual.html" title="pugixml 1.5">
-<link rel="prev" href="saving.html" title="Saving document">
-<link rel="next" href="changes.html" title="Changelog">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <b>XPath</b> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="saving.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="changes.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-<hr>
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="manual.xpath"></a><a class="link" href="xpath.html" title="XPath"> XPath</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="xpath.html#manual.xpath.types"> XPath types</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.select"> Selecting nodes via XPath expression</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.query"> Using query objects</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.variables"> Using variables</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.errors"> Error handling</a></span></dt>
-<dt><span class="section"><a href="xpath.html#manual.xpath.w3c"> Conformance to W3C specification</a></span></dt>
-</dl></div>
-<p>
- If the task at hand is to select a subset of document nodes that match some
- criteria, it is possible to code a function using the existing traversal functionality
- for any practical criteria. However, often either a data-driven approach is
- desirable, in case the criteria are not predefined and come from a file, or
- it is inconvenient to use traversal interfaces and a higher-level DSL is required.
- There is a standard language for XML processing, XPath, that can be useful
- for these cases. pugixml implements an almost complete subset of XPath 1.0.
- Because of differences in document object model and some performance implications,
- there are minor violations of the official specifications, which can be found
- in <a class="xref" href="xpath.html#manual.xpath.w3c" title="Conformance to W3C specification"> Conformance to W3C specification</a>. The rest of this section describes the interface for XPath
- functionality. Please note that if you wish to learn to use XPath language,
- you have to look for other tutorials or manuals; for example, you can read
- <a href="http://www.w3schools.com/xpath/" target="_top">W3Schools XPath tutorial</a>,
- <a href="http://www.tizag.com/xmlTutorial/xpathtutorial.php" target="_top">XPath tutorial
- at tizag.com</a>, and <a href="http://www.w3.org/TR/xpath/" target="_top">the XPath
- 1.0 specification</a>.
- </p>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.xpath.types"></a><a class="link" href="xpath.html#manual.xpath.types" title="XPath types"> XPath types</a>
-</h3></div></div></div>
-<a name="xpath_value_type"></a><a name="xpath_type_number"></a><a name="xpath_type_string"></a><a name="xpath_type_boolean"></a><a name="xpath_type_node_set"></a><a name="xpath_type_none"></a><p>
- Each XPath expression can have one of the following types: boolean, number,
- string or node set. Boolean type corresponds to <code class="computeroutput"><span class="keyword">bool</span></code>
- type, number type corresponds to <code class="computeroutput"><span class="keyword">double</span></code>
- type, string type corresponds to either <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>
- or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wstring</span></code>, depending on whether <a class="link" href="dom.html#manual.dom.unicode" title="Unicode interface">wide
- character interface is enabled</a>, and node set corresponds to <a class="link" href="xpath.html#xpath_node_set">xpath_node_set</a> type. There is an enumeration,
- <code class="computeroutput"><span class="identifier">xpath_value_type</span></code>, which can
- take the values <code class="computeroutput"><span class="identifier">xpath_type_boolean</span></code>,
- <code class="computeroutput"><span class="identifier">xpath_type_number</span></code>, <code class="computeroutput"><span class="identifier">xpath_type_string</span></code> or <code class="computeroutput"><span class="identifier">xpath_type_node_set</span></code>,
- accordingly.
- </p>
-<a name="xpath_node"></a><a name="xpath_node::node"></a><a name="xpath_node::attribute"></a><a name="xpath_node::parent"></a><p>
- Because an XPath node can be either a node or an attribute, there is a special
- type, <code class="computeroutput"><span class="identifier">xpath_node</span></code>, which is
- a discriminated union of these types. A value of this type contains two node
- handles, one of <code class="computeroutput"><span class="identifier">xml_node</span></code>
- type, and another one of <code class="computeroutput"><span class="identifier">xml_attribute</span></code>
- type; at most one of them can be non-null. The accessors to get these handles
- are available:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xpath_node</span><span class="special">::</span><span class="identifier">node</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xml_attribute</span> <span class="identifier">xpath_node</span><span class="special">::</span><span class="identifier">attribute</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- XPath nodes can be null, in which case both accessors return null handles.
- </p>
-<p>
- Note that as per XPath specification, each XPath node has a parent, which
- can be retrieved via this function:
- </p>
-<pre class="programlisting"><span class="identifier">xml_node</span> <span class="identifier">xpath_node</span><span class="special">::</span><span class="identifier">parent</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">parent</span></code> function returns the
- node's parent if the XPath node corresponds to <code class="computeroutput"><span class="identifier">xml_node</span></code>
- handle (equivalent to <code class="computeroutput"><span class="identifier">node</span><span class="special">().</span><span class="identifier">parent</span><span class="special">()</span></code>), or the node to which the attribute belongs
- to, if the XPath node corresponds to <code class="computeroutput"><span class="identifier">xml_attribute</span></code>
- handle. For null nodes, <code class="computeroutput"><span class="identifier">parent</span></code>
- returns null handle.
- </p>
-<a name="xpath_node::unspecified_bool_type"></a><a name="xpath_node::comparison"></a><p>
- Like node and attribute handles, XPath node handles can be implicitly cast
- to boolean-like object to check if it is a null node, and also can be compared
- for equality with each other.
- </p>
-<a name="xpath_node::ctor"></a><p>
- You can also create XPath nodes with one of the three constructors: the default
- constructor, the constructor that takes node argument, and the constructor
- that takes attribute and node arguments (in which case the attribute must
- belong to the attribute list of the node). The constructor from <code class="computeroutput"><span class="identifier">xml_node</span></code> is implicit, so you can usually
- pass <code class="computeroutput"><span class="identifier">xml_node</span></code> to functions
- that expect <code class="computeroutput"><span class="identifier">xpath_node</span></code>. Apart
- from that you usually don't need to create your own XPath node objects, since
- they are returned to you via selection functions.
- </p>
-<a name="xpath_node_set"></a><p>
- XPath expressions operate not on single nodes, but instead on node sets.
- A node set is a collection of nodes, which can be optionally ordered in either
- a forward document order or a reverse one. Document order is defined in XPath
- specification; an XPath node is before another node in document order if
- it appears before it in XML representation of the corresponding document.
- </p>
-<a name="xpath_node_set::const_iterator"></a><a name="xpath_node_set::begin"></a><a name="xpath_node_set::end"></a><p>
- Node sets are represented by <code class="computeroutput"><span class="identifier">xpath_node_set</span></code>
- object, which has an interface that resembles one of sequential random-access
- containers. It has an iterator type along with usual begin/past-the-end iterator
- accessors:
- </p>
-<pre class="programlisting"><span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">*</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">const_iterator</span><span class="special">;</span>
-<span class="identifier">const_iterator</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">const_iterator</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">end</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<a name="xpath_node_set::index"></a><a name="xpath_node_set::size"></a><a name="xpath_node_set::empty"></a><p>
- And it also can be iterated via indices, just like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="keyword">operator</span><span class="special">[](</span><span class="identifier">size_t</span> <span class="identifier">index</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">size_t</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">size</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">empty</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- All of the above operations have the same semantics as that of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code>:
- the iterators are random-access, all of the above operations are constant
- time, and accessing the element at index that is greater or equal than the
- set size results in undefined behavior. You can use both iterator-based and
- index-based access for iteration, however the iterator-based one can be faster.
- </p>
-<a name="xpath_node_set::type"></a><a name="xpath_node_set::type_unsorted"></a><a name="xpath_node_set::type_sorted"></a><a name="xpath_node_set::type_sorted_reverse"></a><a name="xpath_node_set::sort"></a><p>
- The order of iteration depends on the order of nodes inside the set; the
- order can be queried via the following function:
- </p>
-<pre class="programlisting"><span class="keyword">enum</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">type_t</span> <span class="special">{</span><span class="identifier">type_unsorted</span><span class="special">,</span> <span class="identifier">type_sorted</span><span class="special">,</span> <span class="identifier">type_sorted_reverse</span><span class="special">};</span>
-<span class="identifier">type_t</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">type</span></code> function returns the
- current order of nodes; <code class="computeroutput"><span class="identifier">type_sorted</span></code>
- means that the nodes are in forward document order, <code class="computeroutput"><span class="identifier">type_sorted_reverse</span></code>
- means that the nodes are in reverse document order, and <code class="computeroutput"><span class="identifier">type_unsorted</span></code>
- means that neither order is guaranteed (nodes can accidentally be in a sorted
- order even if <code class="computeroutput"><span class="identifier">type</span><span class="special">()</span></code>
- returns <code class="computeroutput"><span class="identifier">type_unsorted</span></code>). If
- you require a specific order of iteration, you can change it via <code class="computeroutput"><span class="identifier">sort</span></code> function:
- </p>
-<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">sort</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">reverse</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">);</span>
-</pre>
-<p>
- Calling <code class="computeroutput"><span class="identifier">sort</span></code> sorts the nodes
- in either forward or reverse document order, depending on the argument; after
- this call <code class="computeroutput"><span class="identifier">type</span><span class="special">()</span></code>
- will return <code class="computeroutput"><span class="identifier">type_sorted</span></code> or
- <code class="computeroutput"><span class="identifier">type_sorted_reverse</span></code>.
- </p>
-<a name="xpath_node_set::first"></a><p>
- Often the actual iteration is not needed; instead, only the first element
- in document order is required. For this, a special accessor is provided:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_node</span> <span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">first</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- This function returns the first node in forward document order from the set,
- or null node if the set is empty. Note that while the result of the node
- does not depend on the order of nodes in the set (i.e. on the result of
- <code class="computeroutput"><span class="identifier">type</span><span class="special">()</span></code>),
- the complexity does - if the set is sorted, the complexity is constant, otherwise
- it is linear in the number of elements or worse.
- </p>
-<a name="xpath_node_set::ctor"></a><p>
- While in the majority of cases the node set is returned by XPath functions,
- sometimes there is a need to manually construct a node set. For such cases,
- a constructor is provided which takes an iterator range (<code class="computeroutput"><span class="identifier">const_iterator</span></code>
- is a typedef for <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">*</span></code>), and an optional type:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">xpath_node_set</span><span class="special">(</span><span class="identifier">const_iterator</span> <span class="identifier">begin</span><span class="special">,</span> <span class="identifier">const_iterator</span> <span class="identifier">end</span><span class="special">,</span> <span class="identifier">type_t</span> <span class="identifier">type</span> <span class="special">=</span> <span class="identifier">type_unsorted</span><span class="special">);</span>
-</pre>
-<p>
- The constructor copies the specified range and sets the specified type. The
- objects in the range are not checked in any way; you'll have to ensure that
- the range contains no duplicates, and that the objects are sorted according
- to the <code class="computeroutput"><span class="identifier">type</span></code> parameter. Otherwise
- XPath operations with this set may produce unexpected results.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.xpath.select"></a><a class="link" href="xpath.html#manual.xpath.select" title="Selecting nodes via XPath expression"> Selecting nodes via XPath expression</a>
-</h3></div></div></div>
-<a name="xml_node::select_node"></a><a name="xml_node::select_nodes"></a><p>
- If you want to select nodes that match some XPath expression, you can do
- it with the following functions:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_node</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xpath_node_set</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- <code class="computeroutput"><span class="identifier">select_nodes</span></code> function compiles
- the expression and then executes it with the node as a context node, and
- returns the resulting node set. <code class="computeroutput"><span class="identifier">select_node</span></code>
- returns only the first node in document order from the result, and is equivalent
- to calling <code class="computeroutput"><span class="identifier">select_nodes</span><span class="special">(</span><span class="identifier">query</span><span class="special">).</span><span class="identifier">first</span><span class="special">()</span></code>.
- If the XPath expression does not match anything, or the node handle is null,
- <code class="computeroutput"><span class="identifier">select_nodes</span></code> returns an empty
- set, and <code class="computeroutput"><span class="identifier">select_node</span></code> returns
- null XPath node.
- </p>
-<p>
- If exception handling is not disabled, both functions throw <a class="link" href="xpath.html#xpath_exception">xpath_exception</a>
- if the query can not be compiled or if it returns a value with type other
- than node set; see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a> for details.
- </p>
-<a name="xml_node::select_node_precomp"></a><a name="xml_node::select_nodes_precomp"></a><p>
- While compiling expressions is fast, the compilation time can introduce a
- significant overhead if the same expression is used many times on small subtrees.
- If you're doing many similar queries, consider compiling them into query
- objects (see <a class="xref" href="xpath.html#manual.xpath.query" title="Using query objects"> Using query objects</a> for further reference). Once you get a compiled
- query object, you can pass it to select functions instead of an expression
- string:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_node</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_query</span><span class="special">&amp;</span> <span class="identifier">query</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xpath_node_set</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_query</span><span class="special">&amp;</span> <span class="identifier">query</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- If exception handling is not disabled, both functions throw <a class="link" href="xpath.html#xpath_exception">xpath_exception</a>
- if the query returns a value with type other than node set.
- </p>
-<p>
- This is an example of selecting nodes using XPath expressions (<a href="../samples/xpath_select.cpp" target="_top">samples/xpath_select.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tools:\n"</span><span class="special">;</span>
-
-<span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="special">*</span><span class="identifier">it</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-<span class="special">}</span>
-
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node</span> <span class="identifier">build_tool</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_node</span><span class="special">(</span><span class="string">"//Tool[contains(Description, 'build system')]"</span><span class="special">);</span>
-
-<span class="keyword">if</span> <span class="special">(</span><span class="identifier">build_tool</span><span class="special">)</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Build tool: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">build_tool</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.xpath.query"></a><a class="link" href="xpath.html#manual.xpath.query" title="Using query objects"> Using query objects</a>
-</h3></div></div></div>
-<a name="xpath_query"></a><p>
- When you call <code class="computeroutput"><span class="identifier">select_nodes</span></code>
- with an expression string as an argument, a query object is created behind
- the scenes. A query object represents a compiled XPath expression. Query
- objects can be needed in the following circumstances:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- You can precompile expressions to query objects to save compilation time
- if it becomes an issue;
- </li>
-<li class="listitem">
- You can use query objects to evaluate XPath expressions which result
- in booleans, numbers or strings;
- </li>
-<li class="listitem">
- You can get the type of expression value via query object.
- </li>
-</ul></div>
-<p>
- Query objects correspond to <code class="computeroutput"><span class="identifier">xpath_query</span></code>
- type. They are immutable and non-copyable: they are bound to the expression
- at creation time and can not be cloned. If you want to put query objects
- in a container, allocate them on heap via <code class="computeroutput"><span class="keyword">new</span></code>
- operator and store pointers to <code class="computeroutput"><span class="identifier">xpath_query</span></code>
- in the container.
- </p>
-<a name="xpath_query::ctor"></a><p>
- You can create a query object with the constructor that takes XPath expression
- as an argument:
- </p>
-<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">xpath_query</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
-</pre>
-<a name="xpath_query::return_type"></a><p>
- The expression is compiled and the compiled representation is stored in the
- new query object. If compilation fails, <a class="link" href="xpath.html#xpath_exception">xpath_exception</a>
- is thrown if exception handling is not disabled (see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a> for
- details). After the query is created, you can query the type of the evaluation
- result using the following function:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_value_type</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">return_type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<a name="xpath_query::evaluate_boolean"></a><a name="xpath_query::evaluate_number"></a><a name="xpath_query::evaluate_string"></a><a name="xpath_query::evaluate_node_set"></a><a name="xpath_query::evaluate_node"></a><p>
- You can evaluate the query using one of the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_boolean</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">double</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_number</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">string_t</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_string</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xpath_node_set</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xpath_node</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_node</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- All functions take the context node as an argument, compute the expression
- and return the result, converted to the requested type. According to XPath
- specification, value of any type can be converted to boolean, number or string
- value, but no type other than node set can be converted to node set. Because
- of this, <code class="computeroutput"><span class="identifier">evaluate_boolean</span></code>,
- <code class="computeroutput"><span class="identifier">evaluate_number</span></code> and <code class="computeroutput"><span class="identifier">evaluate_string</span></code> always return a result,
- but <code class="computeroutput"><span class="identifier">evaluate_node_set</span></code> and
- <code class="computeroutput"><span class="identifier">evaluate_node</span></code> result in an
- error if the return type is not node set (see <a class="xref" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a>).
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- Calling <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"query"</span><span class="special">)</span></code>
- is equivalent to calling <code class="computeroutput"><span class="identifier">xpath_query</span><span class="special">(</span><span class="string">"query"</span><span class="special">).</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="identifier">node</span><span class="special">)</span></code>. Calling <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">select_node</span><span class="special">(</span><span class="string">"query"</span><span class="special">)</span></code> is equivalent to calling <code class="computeroutput"><span class="identifier">xpath_query</span><span class="special">(</span><span class="string">"query"</span><span class="special">).</span><span class="identifier">evaluate_node</span><span class="special">(</span><span class="identifier">node</span><span class="special">)</span></code>.
- </p></td></tr>
-</table></div>
-<a name="xpath_query::evaluate_string_buffer"></a><p>
- Note that <code class="computeroutput"><span class="identifier">evaluate_string</span></code>
- function returns the STL string; as such, it's not available in <a class="link" href="install.html#PUGIXML_NO_STL">PUGIXML_NO_STL</a>
- mode and also usually allocates memory. There is another string evaluation
- function:
- </p>
-<pre class="programlisting"><span class="identifier">size_t</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">evaluate_string</span><span class="special">(</span><span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">capacity</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xpath_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- This function evaluates the string, and then writes the result to <code class="computeroutput"><span class="identifier">buffer</span></code> (but at most <code class="computeroutput"><span class="identifier">capacity</span></code>
- characters); then it returns the full size of the result in characters, including
- the terminating zero. If <code class="computeroutput"><span class="identifier">capacity</span></code>
- is not 0, the resulting buffer is always zero-terminated. You can use this
- function as follows:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- First call the function with <code class="computeroutput"><span class="identifier">buffer</span>
- <span class="special">=</span> <span class="number">0</span></code>
- and <code class="computeroutput"><span class="identifier">capacity</span> <span class="special">=</span>
- <span class="number">0</span></code>; then allocate the returned amount
- of characters, and call the function again, passing the allocated storage
- and the amount of characters;
- </li>
-<li class="listitem">
- First call the function with small buffer and buffer capacity; then,
- if the result is larger than the capacity, the output has been trimmed,
- so allocate a larger buffer and call the function again.
- </li>
-</ul></div>
-<p>
- This is an example of using query objects (<a href="../samples/xpath_query.cpp" target="_top">samples/xpath_query.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// Select nodes via compiled query
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_remote_tools</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote='true']"</span><span class="special">);</span>
-
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools</span> <span class="special">=</span> <span class="identifier">query_remote_tools</span><span class="special">.</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="identifier">doc</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Remote tool: "</span><span class="special">;</span>
-<span class="identifier">tools</span><span class="special">[</span><span class="number">2</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-
-<span class="comment">// Evaluate numbers via compiled query
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_timeouts</span><span class="special">(</span><span class="string">"sum(//Tool/@Timeout)"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">query_timeouts</span><span class="special">.</span><span class="identifier">evaluate_number</span><span class="special">(</span><span class="identifier">doc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// Evaluate strings via compiled query for different context nodes
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_name_valid</span><span class="special">(</span><span class="string">"string-length(substring-before(@Filename, '_')) &gt; 0 and @OutputFileMasks"</span><span class="special">);</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_name</span><span class="special">(</span><span class="string">"concat(substring-before(@Filename, '_'), ' produces ', @OutputFileMasks)"</span><span class="special">);</span>
-
-<span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">first_element_by_path</span><span class="special">(</span><span class="string">"Profile/Tools/Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">())</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">s</span> <span class="special">=</span> <span class="identifier">query_name</span><span class="special">.</span><span class="identifier">evaluate_string</span><span class="special">(</span><span class="identifier">tool</span><span class="special">);</span>
-
- <span class="keyword">if</span> <span class="special">(</span><span class="identifier">query_name_valid</span><span class="special">.</span><span class="identifier">evaluate_boolean</span><span class="special">(</span><span class="identifier">tool</span><span class="special">))</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">s</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.xpath.variables"></a><a class="link" href="xpath.html#manual.xpath.variables" title="Using variables"> Using variables</a>
-</h3></div></div></div>
-<p>
- XPath queries may contain references to variables; this is useful if you
- want to use queries that depend on some dynamic parameter without manually
- preparing the complete query string, or if you want to reuse the same query
- object for similar queries.
- </p>
-<p>
- Variable references have the form <code class="computeroutput"><span class="identifier">$name</span></code>; in order to use them, you have to provide
- a variable set, which includes all variables present in the query with correct
- types. This set is passed to <code class="computeroutput"><span class="identifier">xpath_query</span></code>
- constructor or to <code class="computeroutput"><span class="identifier">select_nodes</span></code>/<code class="computeroutput"><span class="identifier">select_node</span></code> functions:
- </p>
-<pre class="programlisting"><span class="keyword">explicit</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">xpath_query</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">);</span>
-<span class="identifier">xpath_node</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_node</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xpath_node_set</span> <span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">query</span><span class="special">,</span> <span class="identifier">xpath_variable_set</span><span class="special">*</span> <span class="identifier">variables</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- If you're using query objects, you can change the variable values before
- <code class="computeroutput"><span class="identifier">evaluate</span></code>/<code class="computeroutput"><span class="identifier">select</span></code>
- calls to change the query behavior.
- </p>
-<div class="note"><table border="0" summary="Note">
-<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.png"></td>
-<th align="left">Note</th>
-</tr>
-<tr><td align="left" valign="top"><p>
- The variable set pointer is stored in the query object; you have to ensure
- that the lifetime of the set exceeds that of query object.
- </p></td></tr>
-</table></div>
-<a name="xpath_variable_set"></a><p>
- Variable sets correspond to <code class="computeroutput"><span class="identifier">xpath_variable_set</span></code>
- type, which is essentially a variable container.
- </p>
-<a name="xpath_variable_set::add"></a><p>
- You can add new variables with the following function:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_variable</span><span class="special">*</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">add</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">xpath_value_type</span> <span class="identifier">type</span><span class="special">);</span>
-</pre>
-<p>
- The function tries to add a new variable with the specified name and type;
- if the variable with such name does not exist in the set, the function adds
- a new variable and returns the variable handle; if there is already a variable
- with the specified name, the function returns the variable handle if variable
- has the specified type. Otherwise the function returns null pointer; it also
- returns null pointer on allocation failure.
- </p>
-<p>
- New variables are assigned the default value which depends on the type:
- <code class="computeroutput"><span class="number">0</span></code> for numbers, <code class="computeroutput"><span class="keyword">false</span></code> for booleans, empty string for strings
- and empty set for node sets.
- </p>
-<a name="xpath_variable_set::get"></a><p>
- You can get the existing variables with the following functions:
- </p>
-<pre class="programlisting"><span class="identifier">xpath_variable</span><span class="special">*</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">get</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
-<span class="keyword">const</span> <span class="identifier">xpath_variable</span><span class="special">*</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">get</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- The functions return the variable handle, or null pointer if the variable
- with the specified name is not found.
- </p>
-<a name="xpath_variable_set::set"></a><p>
- Additionally, there are the helper functions for setting the variable value
- by name; they try to add the variable with the corresponding type, if it
- does not exist, and to set the value. If the variable with the same name
- but with different type is already present, they return <code class="computeroutput"><span class="keyword">false</span></code>;
- they also return <code class="computeroutput"><span class="keyword">false</span></code> on allocation
- failure. Note that these functions do not perform any type conversions.
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">double</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_variable_set</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">);</span>
-</pre>
-<p>
- The variable values are copied to the internal variable storage, so you can
- modify or destroy them after the functions return.
- </p>
-<a name="xpath_variable"></a><p>
- If setting variables by name is not efficient enough, or if you have to inspect
- variable information or get variable values, you can use variable handles.
- A variable corresponds to the <code class="computeroutput"><span class="identifier">xpath_variable</span></code>
- type, and a variable handle is simply a pointer to <code class="computeroutput"><span class="identifier">xpath_variable</span></code>.
- </p>
-<a name="xpath_variable::type"></a><a name="xpath_variable::name"></a><p>
- In order to get variable information, you can use one of the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">name</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="identifier">xpath_value_type</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">type</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- Note that each variable has a distinct type which is specified upon variable
- creation and can not be changed later.
- </p>
-<a name="xpath_variable::get_boolean"></a><a name="xpath_variable::get_number"></a><a name="xpath_variable::get_string"></a><a name="xpath_variable::get_node_set"></a><p>
- In order to get variable value, you should use one of the following functions,
- depending on the variable type:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">get_boolean</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">double</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">get_number</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">get_string</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&amp;</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">get_node_set</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- These functions return the value of the variable. Note that no type conversions
- are performed; if the type mismatch occurs, a dummy value is returned (<code class="computeroutput"><span class="keyword">false</span></code> for booleans, <code class="computeroutput"><span class="identifier">NaN</span></code>
- for numbers, empty string for strings and empty set for node sets).
- </p>
-<a name="xpath_variable::set"></a><p>
- In order to set variable value, you should use one of the following functions,
- depending on the variable type:
- </p>
-<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">char_t</span><span class="special">*</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">xpath_variable</span><span class="special">::</span><span class="identifier">set</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">xpath_node_set</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">);</span>
-</pre>
-<p>
- These functions modify the variable value. Note that no type conversions
- are performed; if the type mismatch occurs, the functions return <code class="computeroutput"><span class="keyword">false</span></code>; they also return <code class="computeroutput"><span class="keyword">false</span></code>
- on allocation failure. The variable values are copied to the internal variable
- storage, so you can modify or destroy them after the functions return.
- </p>
-<p>
- This is an example of using variables in XPath queries (<a href="../samples/xpath_variables.cpp" target="_top">samples/xpath_variables.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// Select nodes via compiled query
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_variable_set</span> <span class="identifier">vars</span><span class="special">;</span>
-<span class="identifier">vars</span><span class="special">.</span><span class="identifier">add</span><span class="special">(</span><span class="string">"remote"</span><span class="special">,</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_type_boolean</span><span class="special">);</span>
-
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_query</span> <span class="identifier">query_remote_tools</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">vars</span><span class="special">);</span>
-
-<span class="identifier">vars</span><span class="special">.</span><span class="identifier">set</span><span class="special">(</span><span class="string">"remote"</span><span class="special">,</span> <span class="keyword">true</span><span class="special">);</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools_remote</span> <span class="special">=</span> <span class="identifier">query_remote_tools</span><span class="special">.</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="identifier">doc</span><span class="special">);</span>
-
-<span class="identifier">vars</span><span class="special">.</span><span class="identifier">set</span><span class="special">(</span><span class="string">"remote"</span><span class="special">,</span> <span class="keyword">false</span><span class="special">);</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools_local</span> <span class="special">=</span> <span class="identifier">query_remote_tools</span><span class="special">.</span><span class="identifier">evaluate_node_set</span><span class="special">(</span><span class="identifier">doc</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Remote tool: "</span><span class="special">;</span>
-<span class="identifier">tools_remote</span><span class="special">[</span><span class="number">2</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Local tool: "</span><span class="special">;</span>
-<span class="identifier">tools_local</span><span class="special">[</span><span class="number">0</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-
-<span class="comment">// You can pass the context directly to select_nodes/select_node
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools_local_imm</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote = string($remote)]"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">vars</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Local tool imm: "</span><span class="special">;</span>
-<span class="identifier">tools_local_imm</span><span class="special">[</span><span class="number">0</span><span class="special">].</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">print</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.xpath.errors"></a><a class="link" href="xpath.html#manual.xpath.errors" title="Error handling"> Error handling</a>
-</h3></div></div></div>
-<p>
- There are two different mechanisms for error handling in XPath implementation;
- the mechanism used depends on whether exception support is disabled (this
- is controlled with <a class="link" href="install.html#PUGIXML_NO_EXCEPTIONS">PUGIXML_NO_EXCEPTIONS</a>
- define).
- </p>
-<a name="xpath_exception"></a><a name="xpath_exception::result"></a><a name="xpath_exception::what"></a><p>
- By default, XPath functions throw <code class="computeroutput"><span class="identifier">xpath_exception</span></code>
- object in case of errors; additionally, in the event any memory allocation
- fails, an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">bad_alloc</span></code> exception is thrown. Also <code class="computeroutput"><span class="identifier">xpath_exception</span></code> is thrown if the query
- is evaluated to a node set, but the return type is not node set. If the query
- constructor succeeds (i.e. no exception is thrown), the query object is valid.
- Otherwise you can get the error details via one of the following functions:
- </p>
-<pre class="programlisting"><span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">xpath_exception</span><span class="special">::</span><span class="identifier">what</span><span class="special">()</span> <span class="keyword">const</span> <span class="keyword">throw</span><span class="special">();</span>
-<span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&amp;</span> <span class="identifier">xpath_exception</span><span class="special">::</span><span class="identifier">result</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<a name="xpath_query::unspecified_bool_type"></a><a name="xpath_query::result"></a><p>
- If exceptions are disabled, then in the event of parsing failure the query
- is initialized to invalid state; you can test if the query object is valid
- by using it in a boolean expression: <code class="computeroutput"><span class="keyword">if</span>
- <span class="special">(</span><span class="identifier">query</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span></code>. Additionally, you can get parsing
- result via the result() accessor:
- </p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">xpath_parse_result</span><span class="special">&amp;</span> <span class="identifier">xpath_query</span><span class="special">::</span><span class="identifier">result</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-</pre>
-<p>
- Without exceptions, evaluating invalid query results in <code class="computeroutput"><span class="keyword">false</span></code>,
- empty string, NaN or an empty node set, depending on the type; evaluating
- a query as a node set results in an empty node set if the return type is
- not node set.
- </p>
-<a name="xpath_parse_result"></a><p>
- The information about parsing result is returned via <code class="computeroutput"><span class="identifier">xpath_parse_result</span></code>
- object. It contains parsing status and the offset of last successfully parsed
- character from the beginning of the source stream:
- </p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xpath_parse_result</span>
-<span class="special">{</span>
- <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">error</span><span class="special">;</span>
- <span class="identifier">ptrdiff_t</span> <span class="identifier">offset</span><span class="special">;</span>
-
- <span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
- <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">description</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
-<span class="special">};</span>
-</pre>
-<a name="xpath_parse_result::error"></a><p>
- Parsing result is represented as the error message; it is either a null pointer,
- in case there is no error, or the error message in the form of ASCII zero-terminated
- string.
- </p>
-<a name="xpath_parse_result::description"></a><p>
- <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code>
- member function can be used to get the error message; it never returns the
- null pointer, so you can safely use <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> even if query parsing succeeded. Note that
- <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code>
- returns a <code class="computeroutput"><span class="keyword">char</span></code> string even in
- <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code>; you'll
- have to call <a class="link" href="dom.html#as_wide">as_wide</a> to get the <code class="computeroutput"><span class="keyword">wchar_t</span></code> string.
- </p>
-<a name="xpath_parse_result::offset"></a><p>
- In addition to the error message, parsing result has an <code class="computeroutput"><span class="identifier">offset</span></code>
- member, which contains the offset of last successfully parsed character.
- This offset is in units of <a class="link" href="dom.html#char_t">pugi::char_t</a> (bytes
- for character mode, wide characters for wide character mode).
- </p>
-<a name="xpath_parse_result::bool"></a><p>
- Parsing result object can be implicitly converted to <code class="computeroutput"><span class="keyword">bool</span></code>
- like this: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">result</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span>
- <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>.
- </p>
-<p>
- This is an example of XPath error handling (<a href="../samples/xpath_error.cpp" target="_top">samples/xpath_error.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// Exception is thrown for incorrect query syntax
-</span><span class="keyword">try</span>
-<span class="special">{</span>
- <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"//nodes[#true()]"</span><span class="special">);</span>
-<span class="special">}</span>
-<span class="keyword">catch</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_exception</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Select failed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-
-<span class="comment">// Exception is thrown for incorrect query semantics
-</span><span class="keyword">try</span>
-<span class="special">{</span>
- <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"(123)/next"</span><span class="special">);</span>
-<span class="special">}</span>
-<span class="keyword">catch</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_exception</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Select failed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-
-<span class="comment">// Exception is thrown for query with incorrect return type
-</span><span class="keyword">try</span>
-<span class="special">{</span>
- <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"123"</span><span class="special">);</span>
-<span class="special">}</span>
-<span class="keyword">catch</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_exception</span><span class="special">&amp;</span> <span class="identifier">e</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Select failed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="manual.xpath.w3c"></a><a class="link" href="xpath.html#manual.xpath.w3c" title="Conformance to W3C specification"> Conformance to W3C specification</a>
-</h3></div></div></div>
-<p>
- Because of the differences in document object models, performance considerations
- and implementation complexity, pugixml does not provide a fully conformant
- XPath 1.0 implementation. This is the current list of incompatibilities:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Consecutive text nodes sharing the same parent are not merged, i.e. in
- <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;</span><span class="identifier">text1</span>
- <span class="special">&lt;![</span><span class="identifier">CDATA</span><span class="special">[</span><span class="identifier">data</span><span class="special">]]&gt;</span> <span class="identifier">text2</span><span class="special">&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code> node should have one text node child,
- but instead has three.
- </li>
-<li class="listitem">
- Since the document type declaration is not used for parsing, <code class="computeroutput"><span class="identifier">id</span><span class="special">()</span></code>
- function always returns an empty node set.
- </li>
-<li class="listitem">
- Namespace nodes are not supported (affects namespace:: axis).
- </li>
-<li class="listitem">
- Name tests are performed on QNames in XML document instead of expanded
- names; for <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">foo</span>
- <span class="identifier">xmlns</span><span class="special">:</span><span class="identifier">ns1</span><span class="special">=</span><span class="char">'uri'</span> <span class="identifier">xmlns</span><span class="special">:</span><span class="identifier">ns2</span><span class="special">=</span><span class="char">'uri'</span><span class="special">&gt;&lt;</span><span class="identifier">ns1</span><span class="special">:</span><span class="identifier">child</span><span class="special">/&gt;&lt;</span><span class="identifier">ns2</span><span class="special">:</span><span class="identifier">child</span><span class="special">/&gt;&lt;/</span><span class="identifier">foo</span><span class="special">&gt;</span></code>,
- query <code class="computeroutput"><span class="identifier">foo</span><span class="special">/</span><span class="identifier">ns1</span><span class="special">:*</span></code>
- will return only the first child, not both of them. Compliant XPath implementations
- can return both nodes if the user provides appropriate namespace declarations.
- </li>
-<li class="listitem">
- String functions consider a character to be either a single <code class="computeroutput"><span class="keyword">char</span></code> value or a single <code class="computeroutput"><span class="keyword">wchar_t</span></code>
- value, depending on the library configuration; this means that some string
- functions are not fully Unicode-aware. This affects <code class="computeroutput"><span class="identifier">substring</span><span class="special">()</span></code>, <code class="computeroutput"><span class="identifier">string</span><span class="special">-</span><span class="identifier">length</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">translate</span><span class="special">()</span></code> functions.
- </li>
-</ul></div>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><div class="copyright-footer">Copyright &#169; 2014 Arseny Kapoulkine<p>
- Distributed under the MIT License
- </p>
-</div></td>
-</tr></table>
-<hr>
-<table width="100%"><tr>
-<td>
-<a href="http://pugixml.org/">pugixml 1.5</a> manual |
- <a href="../manual.html">Overview</a> |
- <a href="install.html">Installation</a> |
- Document:
- <a href="dom.html">Object model</a> &middot; <a href="loading.html">Loading</a> &middot; <a href="access.html">Accessing</a> &middot; <a href="modify.html">Modifying</a> &middot; <a href="saving.html">Saving</a> |
- <b>XPath</b> |
- <a href="apiref.html">API Reference</a> |
- <a href="toc.html">Table of Contents</a>
-</td>
-<td width="*" align="right"><div class="spirit-nav">
-<a accesskey="p" href="saving.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../manual.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../manual.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="changes.html"><img src="../images/next.png" alt="Next"></a>
-</div></td>
-</tr></table>
-</body>
-</html>
diff --git a/docs/pugixml.css b/docs/pugixml.css
deleted file mode 100644
index 0a72f78..0000000
--- a/docs/pugixml.css
+++ /dev/null
@@ -1,598 +0,0 @@
-/*=============================================================================
- Copyright (c) 2004 Joel de Guzman
- http://spirit.sourceforge.net/
-
- Distributed under the Boost Software License, Version 1.0. (See accompany-
- ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-
-/*=============================================================================
- Body defaults
-=============================================================================*/
-
- body
- {
- margin: 1em;
- font-family: sans-serif;
- }
-
-/*=============================================================================
- Paragraphs
-=============================================================================*/
-
- p
- {
- text-align: left;
- font-size: 10pt;
- line-height: 1.15;
- }
-
-/*=============================================================================
- Program listings
-=============================================================================*/
-
- /* Code on paragraphs */
- p tt.computeroutput
- {
- font-size: 9pt;
- }
-
- pre.synopsis
- {
- font-size: 90%;
- margin: 1pc 4% 0pc 4%;
- padding: 0.5pc 0.5pc 0.5pc 0.5pc;
- }
-
- .programlisting,
- .screen
- {
- font-size: 9pt;
- display: block;
- margin: 1pc 4% 0pc 4%;
- padding: 0.5pc 0.5pc 0.5pc 0.5pc;
- }
-
- /* Program listings in tables don't get borders */
- td .programlisting,
- td .screen
- {
- margin: 0pc 0pc 0pc 0pc;
- padding: 0pc 0pc 0pc 0pc;
- }
-
-/*=============================================================================
- Headings
-=============================================================================*/
-
- h1, h2, h3, h4, h5, h6
- {
- text-align: left;
- margin: 1em 0em 0.5em 0em;
- font-weight: bold;
- }
-
- h1 { font: 140% }
- h2 { font: bold 140% }
- h3 { font: bold 130% }
- h4 { font: bold 120% }
- h5 { font: italic 110% }
- h6 { font: italic 100% }
-
- /* Top page titles */
- title,
- h1.title,
- h2.title
- h3.title,
- h4.title,
- h5.title,
- h6.title,
- .refentrytitle
- {
- font-weight: bold;
- margin-bottom: 1pc;
- }
-
- h1.title { font-size: 140% }
- h2.title { font-size: 140% }
- h3.title { font-size: 130% }
- h4.title { font-size: 120% }
- h5.title { font-size: 110% }
- h6.title { font-size: 100% }
-
- .section h1
- {
- margin: 0em 0em 0.5em 0em;
- font-size: 140%;
- }
-
- .section h2 { font-size: 140% }
- .section h3 { font-size: 130% }
- .section h4 { font-size: 120% }
- .section h5 { font-size: 110% }
- .section h6 { font-size: 100% }
-
- /* Code on titles */
- h1 tt.computeroutput { font-size: 140% }
- h2 tt.computeroutput { font-size: 140% }
- h3 tt.computeroutput { font-size: 130% }
- h4 tt.computeroutput { font-size: 130% }
- h5 tt.computeroutput { font-size: 130% }
- h6 tt.computeroutput { font-size: 130% }
-
-
-/*=============================================================================
- Author
-=============================================================================*/
-
- h3.author
- {
- font-size: 100%
- }
-
-/*=============================================================================
- Lists
-=============================================================================*/
-
- li
- {
- font-size: 10pt;
- line-height: 1.3;
- }
-
- /* Unordered lists */
- ul
- {
- text-align: left;
- }
-
- /* Ordered lists */
- ol
- {
- text-align: left;
- }
-
-/*=============================================================================
- Links
-=============================================================================*/
-
- a
- {
- text-decoration: none; /* no underline */
- }
-
- a:hover
- {
- text-decoration: underline;
- }
-
-/*=============================================================================
- Spirit style navigation
-=============================================================================*/
-
- .spirit-nav
- {
- text-align: right;
- }
-
- .spirit-nav a
- {
- color: white;
- padding-left: 0.5em;
- }
-
- .spirit-nav img
- {
- border-width: 0px;
- }
-
-/*=============================================================================
- Copyright footer
-=============================================================================*/
- .copyright-footer
- {
- text-align: right;
- font-size: 70%;
- }
-
- .copyright-footer p
- {
- text-align: right;
- font-size: 80%;
- }
-
-/*=============================================================================
- Table of contents
-=============================================================================*/
-
- .toc
- {
- margin: 1pc 4% 0pc 4%;
- padding: 0.1pc 1pc 0.1pc 1pc;
- font-size: 80%;
- line-height: 1.15;
- }
-
- .boost-toc
- {
- float: right;
- padding: 0.5pc;
- }
-
- /* Code on toc */
- .toc .computeroutput { font-size: 120% }
-
-/*=============================================================================
- Tables
-=============================================================================*/
-
- .table-title,
- div.table p.title
- {
- margin-left: 4%;
- padding-right: 0.5em;
- padding-left: 0.5em;
- }
-
- .informaltable table,
- .table table
- {
- width: 92%;
- margin-left: 4%;
- margin-right: 4%;
- }
-
- div.informaltable table,
- div.table table
- {
- padding: 4px;
- }
-
- /* Table Cells */
- div.informaltable table tr td,
- div.table table tr td
- {
- padding: 0.5em;
- text-align: left;
- font-size: 9pt;
- }
-
- div.informaltable table tr th,
- div.table table tr th
- {
- padding: 0.5em 0.5em 0.5em 0.5em;
- border: 1pt solid white;
- font-size: 80%;
- }
-
- table.simplelist
- {
- width: auto !important;
- margin: 0em !important;
- padding: 0em !important;
- border: none !important;
- }
- table.simplelist td
- {
- margin: 0em !important;
- padding: 0em !important;
- text-align: left !important;
- font-size: 9pt !important;
- border: none !important;
- }
-
-/*=============================================================================
- Blurbs
-=============================================================================*/
-
- div.note,
- div.tip,
- div.important,
- div.caution,
- div.warning,
- p.blurb
- {
- font-size: 9pt; /* A little bit smaller than the main text */
- line-height: 1.2;
- display: block;
- margin: 1pc 4% 0pc 4%;
- padding: 0.5pc 0.5pc 0.5pc 0.5pc;
- }
-
- p.blurb img
- {
- padding: 1pt;
- }
-
-/*=============================================================================
- Variable Lists
-=============================================================================*/
-
- div.variablelist
- {
- margin: 1em 0;
- }
-
- /* Make the terms in definition lists bold */
- div.variablelist dl dt,
- span.term
- {
- font-weight: bold;
- font-size: 10pt;
- }
-
- div.variablelist table tbody tr td
- {
- text-align: left;
- vertical-align: top;
- padding: 0em 2em 0em 0em;
- font-size: 10pt;
- margin: 0em 0em 0.5em 0em;
- line-height: 1;
- }
-
- div.variablelist dl dt
- {
- margin-bottom: 0.2em;
- }
-
- div.variablelist dl dd
- {
- margin: 0em 0em 0.5em 2em;
- font-size: 10pt;
- }
-
- div.variablelist table tbody tr td p,
- div.variablelist dl dd p
- {
- margin: 0em 0em 0.5em 0em;
- line-height: 1;
- }
-
-/*=============================================================================
- Misc
-=============================================================================*/
-
- /* Title of books and articles in bibliographies */
- span.title
- {
- font-style: italic;
- }
-
- span.underline
- {
- text-decoration: underline;
- }
-
- span.strikethrough
- {
- text-decoration: line-through;
- }
-
- /* Copyright, Legal Notice */
- div div.legalnotice p
- {
- text-align: left
- }
-
-/*=============================================================================
- Colors
-=============================================================================*/
-
- @media screen
- {
- body {
- background-color: #FFFFFF;
- color: #000000;
- }
-
- /* Links */
- a
- {
- color: #005a9c;
- }
-
- a:visited
- {
- color: #9c5a9c;
- }
-
- h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
- h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
- h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
- {
- text-decoration: none; /* no underline */
- color: #000000;
- }
-
- /* Syntax Highlighting */
- .keyword { color: #0000AA; }
- .identifier { color: #000000; }
- .special { color: #707070; }
- .preprocessor { color: #402080; }
- .char { color: teal; }
- .comment { color: #800000; }
- .string { color: teal; }
- .number { color: teal; }
- .white_bkd { background-color: #FFFFFF; }
- .dk_grey_bkd { background-color: #999999; }
-
- /* Copyright, Legal Notice */
- .copyright
- {
- color: #666666;
- font-size: small;
- }
-
- div div.legalnotice p
- {
- color: #666666;
- }
-
- /* Program listing */
- pre.synopsis
- {
- border: 1px solid #DCDCDC;
- }
-
- .programlisting,
- .screen
- {
- border: 1px solid #DCDCDC;
- }
-
- td .programlisting,
- td .screen
- {
- border: 0px solid #DCDCDC;
- }
-
- /* Blurbs */
- div.note,
- div.tip,
- div.important,
- div.caution,
- div.warning,
- p.blurb
- {
- border: 1px solid #DCDCDC;
- }
-
- /* Table of contents */
- .toc
- {
- border: 1px solid #DCDCDC;
- }
-
- /* Tables */
- div.informaltable table tr td,
- div.table table tr td
- {
- border: 1px solid #DCDCDC;
- }
-
- div.informaltable table tr th,
- div.table table tr th
- {
- background-color: #F0F0F0;
- border: 1px solid #DCDCDC;
- }
-
- .copyright-footer
- {
- color: #8F8F8F;
- }
-
- /* Misc */
- span.highlight
- {
- color: #00A000;
- }
- }
-
- @media print
- {
- /* Links */
- a
- {
- color: black;
- }
-
- a:visited
- {
- color: black;
- }
-
- .spirit-nav
- {
- display: none;
- }
-
- /* Program listing */
- pre.synopsis
- {
- border: 1px solid gray;
- }
-
- .programlisting,
- .screen
- {
- border: 1px solid gray;
- }
-
- td .programlisting,
- td .screen
- {
- border: 0px solid #DCDCDC;
- }
-
- /* Table of contents */
- .toc
- {
- border: 1px solid gray;
- }
-
- .informaltable table,
- .table table
- {
- border: 1px solid gray;
- border-collapse: collapse;
- }
-
- /* Tables */
- div.informaltable table tr td,
- div.table table tr td
- {
- border: 1px solid gray;
- }
-
- div.informaltable table tr th,
- div.table table tr th
- {
- border: 1px solid gray;
- }
-
- table.simplelist tr td
- {
- border: none !important;
- }
-
- /* Misc */
- span.highlight
- {
- font-weight: bold;
- }
- }
-
-/*=============================================================================
- Images
-=============================================================================*/
-
- span.inlinemediaobject img
- {
- vertical-align: middle;
- }
-
-/*==============================================================================
- Super and Subscript: style so that line spacing isn't effected, see
- http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=1&postId=5341
-==============================================================================*/
-
-sup,
-sub {
- height: 0;
- line-height: 1;
- vertical-align: baseline;
- _vertical-align: bottom;
- position: relative;
-
-}
-
-sup {
- bottom: 1ex;
-}
-
-sub {
- top: .5ex;
-}
-
diff --git a/docs/quickstart.qbk b/docs/quickstart.adoc
index b609518..4807524 100644
--- a/docs/quickstart.qbk
+++ b/docs/quickstart.adoc
@@ -1,63 +1,50 @@
-[article pugixml
- [quickbook 1.5]
+= pugixml {version} quick start guide
+include::config.adoc[]
- [version 1.5]
- [id quickstart]
- [copyright 2014 Arseny Kapoulkine]
- [license Distributed under the MIT License]
-]
+[[introduction]]
+== Introduction
-[template file[name]'''<filename>'''[name]'''</filename>''']
-[template sref[name]'''<xref linkend="quickstart.main.'''[name]'''" xrefstyle="select:title" />''']
-[template ftnt[id text]'''<footnote id="'''[id]'''"><para>'''[text]'''</para></footnote>''']
-
-[section:main pugixml 1.5 quick start guide]
-
-[section:introduction Introduction]
-
-[@http://pugixml.org/ pugixml] is a light-weight C++ XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is extremely portable and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the [link quickstart.main.license MIT license], making it completely free to use in both open-source and proprietary applications.
+http://pugixml.org/[pugixml] is a light-weight C{plus}{plus} XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with two Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is extremely portable and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the <<license,MIT license>>, making it completely free to use in both open-source and proprietary applications.
pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can't process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD/Schema validation, the library is not for you.
-This is the quick start guide for pugixml, which purpose is to enable you to start using the library quickly. Many important library features are either not described at all or only mentioned briefly; for more complete information you [@manual.html should read the complete manual].
-
-[note No documentation is perfect, neither is this one. If you encounter a description that is unclear, please file an issue as described in [sref feedback]. Also if you can spare the time for a full proof-reading, including spelling and grammar, that would be great! Please [link email send me an e-mail]; as a token of appreciation, your name will be included into the corresponding section of the manual.]
+This is the quick start guide for pugixml, which purpose is to enable you to start using the library quickly. Many important library features are either not described at all or only mentioned briefly; for more complete information you link:manual.html[should read the complete manual].
-[endsect] [/introduction]
+NOTE: No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to https://github.com/zeux/pugixml/issues/new[submit an issue or open a pull request] with a fix.
-[section:install Installation]
+[[install]]
+== Installation
-pugixml is distributed in source form. You can download a source distribution via one of the following links:
+You can download the latest source distribution as an archive:
-[pre
-[@https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.zip]
-[@https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.tar.gz]
-]
+https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.zip[pugixml-{version}.zip] (Windows line endings)
+/
+https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.tar.gz[pugixml-{version}.tar.gz] (Unix line endings)
-The distribution contains library source, documentation (the guide you're reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive. The files have different line endings depending on the archive format - [file .zip] archive has Windows line endings, [file .tar.gz] archive has Unix line endings. Otherwise the files in both archives are identical.
+The distribution contains library source, documentation (the guide you're reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.
-The complete pugixml source consists of three files - one source file, [file pugixml.cpp], and two header files, [file pugixml.hpp] and [file pugiconfig.hpp]. [file pugixml.hpp] is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that [file pugixml.hpp] is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
+The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include <xml/thirdparty/pugixml/src/pugixml.hpp>`).
-The easiest way to build pugixml is to compile the source file, [file pugixml.cpp], along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio[ftnt trademarks All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just add [file pugixml.cpp] to one of your projects. There are other building methods available, including building pugixml as a standalone static/shared library; [@manual/install.html#manual.install.building read the manual] for further information.
+The easiest way to build pugixml is to compile the source file, `pugixml.cpp`, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio footnote:[All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just add `pugixml.cpp` to one of your projects. There are other building methods available, including building pugixml as a standalone static/shared library; link:manual/install.html#install.building[read the manual] for further information.
+[[dom]]
+== Document object model
-[endsect] [/install]
+pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from character stream (file, string, C{plus}{plus} I/O stream), then traversed via special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C{plus}{plus} I/O stream or custom transport).
-[section:dom Document object model]
-
-pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from character stream (file, string, C++ I/O stream), then traversed via special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C++ I/O stream or custom transport).
-
-The root of the tree is the document itself, which corresponds to C++ type `xml_document`. Document has one or more child nodes, which correspond to C++ type `xml_node`. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C++ type `xml_attribute`, and some additional data (i.e. name).
+The root of the tree is the document itself, which corresponds to C{plus}{plus} type `xml_document`. Document has one or more child nodes, which correspond to C{plus}{plus} type `xml_node`. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C{plus}{plus} type `xml_attribute`, and some additional data (i.e. name).
The most common node types are:
* Document node (`node_document`) - this is the root of the tree, which consists of several child nodes. This node corresponds to `xml_document` class; note that `xml_document` is a sub-class of `xml_node`, so the entire node interface is also available.
+
* Element/tag node (`node_element`) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair.
+
* Plain character data nodes (`node_pcdata`) represent plain text in XML. PCDATA nodes have a value, but do not have name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; for example, an element node can have several child PCDATA nodes.
-Despite the fact that there are several node types, there are only three C++ types representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. They are described below.
+Despite the fact that there are several node types, there are only three C{plus}{plus} types representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. They are described below.
-[note All pugixml classes and functions are located in `pugi` namespace; you have to either use explicit name qualification (i.e. `pugi::xml_node`), or to gain access to relevant symbols via `using` directive (i.e. `using pugi::xml_node;` or `using namespace pugi;`).]
+NOTE: All pugixml classes and functions are located in `pugi` namespace; you have to either use explicit name qualification (i.e. `pugi::xml_node`), or to gain access to relevant symbols via `using` directive (i.e. `using pugi::xml_node;` or `using namespace pugi;`).
`xml_document` is the owner of the entire document structure; destroying the document destroys the whole tree. The interface of `xml_document` consists of loading functions, saving functions and the entire interface of `xml_node`, which allows for document inspection and/or modification. Note that while `xml_document` is a sub-class of `xml_node`, `xml_node` is not a polymorphic type; the inheritance is present only to simplify usage.
@@ -67,48 +54,59 @@ There is a special value of `xml_node` type, known as null node or empty node. I
`xml_attribute` is the handle to an XML attribute; it has the same semantics as `xml_node`, i.e. there can be several `xml_attribute` handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.
-There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via `PUGIXML_WCHAR_MODE` define; you can set it via [file pugiconfig.hpp] or via preprocessor options. All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. [@manual/dom.html#manual.dom.unicode Read the manual] for additional information on Unicode interface.
+There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via `PUGIXML_WCHAR_MODE` define; you can set it via `pugiconfig.hpp` or via preprocessor options. All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. link:manual/dom.html#dom.unicode[Read the manual] for additional information on Unicode interface.
-[endsect] [/dom]
+[[loading]]
+== Loading document
-[section:loading Loading document]
-
-pugixml provides several functions for loading XML data from various places - files, C++ iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons. XML data is always converted to internal character format before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions automatically.
+pugixml provides several functions for loading XML data from various places - files, C{plus}{plus} iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons. XML data is always converted to internal character format before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions automatically.
The most common source of XML data is files; pugixml provides a separate function for loading XML document from file. This function accepts file path as its first argument, and also two optional arguments, which specify parsing options and input data encoding, which are described in the manual.
-This is an example of loading XML document from file ([@samples/load_file.cpp]):
+This is an example of loading XML document from file (link:samples/load_file.cpp[]):
-[import samples/load_file.cpp]
-[code_load_file]
+[source,indent=0]
+----
+include::samples/load_file.cpp[tags=code]
+----
`load_file`, as well as other loading functions, destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an `xml_parse_result` object; this object contains the operation status, and the related information (i.e. last successfully parsed position in the input file, if parsing fails).
Parsing result object can be implicitly converted to `bool`; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a `bool`: `if (doc.load_file("file.xml")) { ... } else { ... }`. Otherwise you can use the `status` member to get parsing status, or the `description()` member function to get the status in a string form.
-This is an example of handling loading errors ([@samples/load_error_handling.cpp]):
+This is an example of handling loading errors (link:samples/load_error_handling.cpp[]):
-[import samples/load_error_handling.cpp]
-[code_load_error_handling]
+[source,indent=0]
+----
+include::samples/load_error_handling.cpp[tags=code]
+----
-Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C++ IOstream, in which case you should provide an object which implements `std::istream` or `std::wistream` interface.
+Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C{plus}{plus} IOstream, in which case you should provide an object which implements `std::istream` or `std::wistream` interface.
There are different functions for loading document from memory; they treat the passed buffer as either an immutable one (`load_buffer`), a mutable buffer which is owned by the caller (`load_buffer_inplace`), or a mutable buffer which ownership belongs to pugixml (`load_buffer_inplace_own`). There is also a simple helper function, `xml_document::load`, for cases when you want to load the XML document from null-terminated character string.
-This is an example of loading XML document from memory using one of these functions ([@samples/load_memory.cpp]); read the sample code for more examples:
+This is an example of loading XML document from memory using one of these functions (link:samples/load_memory.cpp[]); read the sample code for more examples:
-[import samples/load_memory.cpp]
-[code_load_memory_decl]
-[code_load_memory_buffer_inplace]
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=decl]
+----
+[source,indent=0]
+----
+include::samples/load_memory.cpp[tags=load_buffer_inplace_begin]
-This is a simple example of loading XML document from file using streams ([@samples/load_stream.cpp]); read the sample code for more complex examples involving wide streams and locales:
+include::samples/load_memory.cpp[tags=load_buffer_inplace_end]
+----
-[import samples/load_stream.cpp]
-[code_load_stream]
+This is a simple example of loading XML document from file using streams (link:samples/load_stream.cpp[]); read the sample code for more complex examples involving wide streams and locales:
-[endsect] [/loading]
+[source,indent=0]
+----
+include::samples/load_stream.cpp[tags=code]
+----
-[section:access Accessing document data]
+[[access]]
+== Accessing document data
pugixml features an extensive interface for getting various types of data from the document and for traversing the document. You can use various accessors to get node/attribute data, you can traverse the child node/attribute lists via accessors or iterators, you can do depth-first traversals with `xml_tree_walker` objects, and you can use XPath for complex data-driven queries.
@@ -118,120 +116,146 @@ You can get node or attribute name via `name()` accessor, and value via `value()
* In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type.
-This is an example of using these functions ([@samples/traverse_base.cpp]):
+This is an example of using these functions (link:samples/traverse_base.cpp[]):
-[import samples/traverse_base.cpp]
-[code_traverse_base_data]
+[source,indent=0]
+----
+include::samples/traverse_base.cpp[tags=data]
+----
-Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose. For example, `child("Tool")` returns the first node which has the name `"Tool"`, or null handle if there is no such node. This is an example of using such functions ([@samples/traverse_base.cpp]):
+Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose. For example, `child("Tool")` returns the first node which has the name `"Tool"`, or null handle if there is no such node. This is an example of using such functions (link:samples/traverse_base.cpp[]):
-[code_traverse_base_contents]
+[source,indent=0]
+----
+include::samples/traverse_base.cpp[tags=contents]
+----
-Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes. All iterators are bidirectional and support all usual iterator operations. The iterators are invalidated if the node\/attribute objects they're pointing to are removed from the tree; adding nodes\/attributes does not invalidate any iterators.
+Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes. All iterators are bidirectional and support all usual iterator operations. The iterators are invalidated if the node/attribute objects they're pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.
-Here is an example of using iterators for document traversal ([@samples/traverse_iter.cpp]):
+Here is an example of using iterators for document traversal (link:samples/traverse_iter.cpp[]):
-[import samples/traverse_iter.cpp]
-[code_traverse_iter]
+[source,indent=0]
+----
+include::samples/traverse_iter.cpp[tags=code]
+----
-If your C++ compiler supports range-based for-loop (this is a C++11 feature, at the time of writing it's supported by Microsoft Visual Studio 11 Beta, GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with [@http://www.boost.org/libs/foreach/ Boost Foreach], and possibly other pre-C++11 foreach facilities.
+If your C{plus}{plus} compiler supports range-based for-loop (this is a C{plus}{plus}11 feature, at the time of writing it's supported by Microsoft Visual Studio 11 Beta, GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with http://www.boost.org/libs/foreach/[Boost Foreach], and possibly other pre-C{plus}{plus}11 foreach facilities.
-Here is an example of using C++11 range-based for loop for document traversal ([@samples/traverse_rangefor.cpp]):
+Here is an example of using C{plus}{plus}11 range-based for loop for document traversal (link:samples/traverse_rangefor.cpp[]):
-[import samples/traverse_rangefor.cpp]
-[code_traverse_rangefor]
+[source,indent=0]
+----
+include::samples/traverse_rangefor.cpp[tags=code]
+----
The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you'll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement `xml_tree_walker` interface and to call `traverse` function.
-This is an example of traversing tree hierarchy with xml_tree_walker ([@samples/traverse_walker.cpp]):
+This is an example of traversing tree hierarchy with xml_tree_walker (link:samples/traverse_walker.cpp[]):
-[import samples/traverse_walker.cpp]
-[code_traverse_walker_impl]
-[code_traverse_walker_traverse]
+[source,indent=0]
+----
+include::samples/traverse_walker.cpp[tags=impl]
+----
+[source,indent=0]
+----
+include::samples/traverse_walker.cpp[tags=traverse]
+----
Finally, for complex queries often a higher-level DSL is needed. pugixml provides an implementation of XPath 1.0 language for such queries. The complete description of XPath usage can be found in the manual, but here are some examples:
-[import samples/xpath_select.cpp]
-[code_xpath_select]
-
-[caution XPath functions throw `xpath_exception` objects on error; the sample above does not catch these exceptions.]
+[source,indent=0]
+----
+include::samples/xpath_select.cpp[tags=code]
+----
-[endsect] [/access]
+CAUTION: XPath functions throw `xpath_exception` objects on error; the sample above does not catch these exceptions.
-[section:modify Modifying document data]
+[[modify]]
+== Modifying document data
The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.
All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: `void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }`, so const-correctness here mainly provides additional documentation.
-As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. You can use `set_name` and `set_value` member functions to set them. Similar functions are available for attributes; however, the `set_value` function is overloaded for some other types except strings, like floating-point numbers. Also, attribute value can be set using an assignment operator. This is an example of setting node/attribute name and value ([@samples/modify_base.cpp]):
+As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. You can use `set_name` and `set_value` member functions to set them. Similar functions are available for attributes; however, the `set_value` function is overloaded for some other types except strings, like floating-point numbers. Also, attribute value can be set using an assignment operator. This is an example of setting node/attribute name and value (link:samples/modify_base.cpp[]):
-[import samples/modify_base.cpp]
-[code_modify_base_node]
-[code_modify_base_attr]
+[source,indent=0]
+----
+include::samples/modify_base.cpp[tags=node]
+----
+[source,indent=0]
+----
+include::samples/modify_base.cpp[tags=attr]
+----
-Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before\/after some other node. All insertion functions return the handle to newly created object on success, and null handle on failure. Even if the operation fails (for example, if you're trying to add a child node to PCDATA node), the document remains in consistent state, but the requested node/attribute is not added.
+Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node. All insertion functions return the handle to newly created object on success, and null handle on failure. Even if the operation fails (for example, if you're trying to add a child node to PCDATA node), the document remains in consistent state, but the requested node/attribute is not added.
-[caution attribute() and child() functions do not add attributes or nodes to the tree, so code like `node.attribute("id") = 123;` will not do anything if `node` does not have an attribute with name `"id"`. Make sure you're operating with existing attributes/nodes by adding them if necessary.]
+CAUTION: `attribute()` and `child()` functions do not add attributes or nodes to the tree, so code like `node.attribute("id") = 123;` will not do anything if `node` does not have an attribute with name `"id"`. Make sure you're operating with existing attributes/nodes by adding them if necessary.
-This is an example of adding new attributes\/nodes to the document ([@samples/modify_add.cpp]):
+This is an example of adding new attributes/nodes to the document (link:samples/modify_add.cpp[]):
-[import samples/modify_add.cpp]
-[code_modify_add]
+[source,indent=0]
+----
+include::samples/modify_add.cpp[tags=code]
+----
-If you do not want your document to contain some node or attribute, you can remove it with `remove_attribute` and `remove_child` functions. Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute\/node is removed.
+If you do not want your document to contain some node or attribute, you can remove it with `remove_attribute` and `remove_child` functions. Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed.
-This is an example of removing attributes\/nodes from the document ([@samples/modify_remove.cpp]):
+This is an example of removing attributes/nodes from the document (link:samples/modify_remove.cpp[]):
-[import samples/modify_remove.cpp]
-[code_modify_remove]
+[source,indent=0]
+----
+include::samples/modify_remove.cpp[tags=code]
+----
-[endsect] [/modify]
-
-[section:saving Saving document]
+[[saving]]
+== Saving document
Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format, and also perform necessary encoding conversions.
Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped. In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values.
-If you want to save the whole document to a file, you can use the `save_file` function, which returns `true` on success. This is a simple example of saving XML document to file ([@samples/save_file.cpp]):
+If you want to save the whole document to a file, you can use the `save_file` function, which returns `true` on success. This is a simple example of saving XML document to file (link:samples/save_file.cpp[]):
-[import samples/save_file.cpp]
-[code_save_file]
+[source,indent=0]
+----
+include::samples/save_file.cpp[tags=code]
+----
-To enhance interoperability pugixml provides functions for saving document to any object which implements C++ `std::ostream` interface. This allows you to save documents to any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones.
+To enhance interoperability pugixml provides functions for saving document to any object which implements C{plus}{plus} `std::ostream` interface. This allows you to save documents to any standard C{plus}{plus} stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones.
-This is a simple example of saving XML document to standard output ([@samples/save_stream.cpp]):
+This is a simple example of saving XML document to standard output (link:samples/save_stream.cpp[]):
-[import samples/save_stream.cpp]
-[code_save_stream]
+[source,indent=0]
+----
+include::samples/save_stream.cpp[tags=code]
+----
All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input. In order to output the document via some custom transport, for example sockets, you should create an object which implements `xml_writer_file` interface and pass it to `xml_document::save` function.
-This is a simple example of custom writer for saving document data to STL string ([@samples/save_custom_writer.cpp]); read the sample code for more complex examples:
-
-[import samples/save_custom_writer.cpp]
-[code_save_custom_writer]
+This is a simple example of custom writer for saving document data to STL string (link:samples/save_custom_writer.cpp[]); read the sample code for more complex examples:
-While the previously described functions save the whole document to the destination, it is easy to save a single subtree. Instead of calling `xml_document::save`, just call `xml_node::print` function on the target node. You can save node contents to C++ IOstream object or custom writer in this way. Saving a subtree slightly differs from saving the whole document; [@manual/saving.html#manual.saving.subtree read the manual] for more information.
+[source,indent=0]
+----
+include::samples/save_custom_writer.cpp[tags=code]
+----
-[endsect] [/saving]
+While the previously described functions save the whole document to the destination, it is easy to save a single subtree. Instead of calling `xml_document::save`, just call `xml_node::print` function on the target node. You can save node contents to C{plus}{plus} IOstream object or custom writer in this way. Saving a subtree slightly differs from saving the whole document; link:manual/saving.html#saving.subtree[read the manual] for more information.
-[section:feedback Feedback]
+[[feedback]]
+== Feedback
-If you believe you've found a bug in pugixml, please file an issue via [@https://github.com/zeux/pugixml/issues/new issue submission form]. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc. Feature requests and contributions can be filed as issues, too.
+If you believe you've found a bug in pugixml, please file an issue via https://github.com/zeux/pugixml/issues/new[issue submission form]. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc. Feature requests and contributions can be filed as issues, too.
-[#email]
-If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: [@mailto:arseny.kapoulkine@gmail.com arseny.kapoulkine@gmail.com].
+If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: arseny.kapoulkine@gmail.com.
-[endsect] [/feedback]
-
-[section:license License]
+[[license]]
+== License
The pugixml library is distributed under the MIT license:
-[:
-Copyright (c) 2006-2014 Arseny Kapoulkine
+....
+Copyright (c) 2006-2015 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -253,17 +277,11 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-]
+....
This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:
-[:
-This software is based on pugixml library (http://pugixml.org).'''<sbr />'''
-pugixml is Copyright (C) 2006-2014 Arseny Kapoulkine.
-]
-
-[endsect] [/license]
-
-[endsect] [/main]
-
-[/ vim:et ]
+....
+This software is based on pugixml library (http://pugixml.org).
+pugixml is Copyright (C) 2006-2015 Arseny Kapoulkine.
+.... \ No newline at end of file
diff --git a/docs/quickstart.html b/docs/quickstart.html
index c702852..2dbed65 100644
--- a/docs/quickstart.html
+++ b/docs/quickstart.html
@@ -1,880 +1,1075 @@
-<html>
+<!DOCTYPE html>
+<html lang="en">
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
-<title>pugixml 1.5</title>
-<link rel="stylesheet" href="pugixml.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
-<link rel="home" href="quickstart.html" title="pugixml 1.5">
+<meta charset="UTF-8">
+<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 1.5.2">
+<meta name="author" content="website, repository">
+<title>pugixml 1.6 quick start guide</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400">
+<style>
+/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
+/* Remove the comments around the @import statement below when using this as a custom stylesheet */
+/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400";*/
+article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
+audio,canvas,video{display:inline-block}
+audio:not([controls]){display:none;height:0}
+[hidden],template{display:none}
+script{display:none!important}
+html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
+body{margin:0}
+a{background:transparent}
+a:focus{outline:thin dotted}
+a:active,a:hover{outline:0}
+h1{font-size:2em;margin:.67em 0}
+abbr[title]{border-bottom:1px dotted}
+b,strong{font-weight:bold}
+dfn{font-style:italic}
+hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
+mark{background:#ff0;color:#000}
+code,kbd,pre,samp{font-family:monospace;font-size:1em}
+pre{white-space:pre-wrap}
+q{quotes:"\201C" "\201D" "\2018" "\2019"}
+small{font-size:80%}
+sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
+sup{top:-.5em}
+sub{bottom:-.25em}
+img{border:0}
+svg:not(:root){overflow:hidden}
+figure{margin:0}
+fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
+legend{border:0;padding:0}
+button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
+button,input{line-height:normal}
+button,select{text-transform:none}
+button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
+button[disabled],html input[disabled]{cursor:default}
+input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
+input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}
+input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}
+button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
+textarea{overflow:auto;vertical-align:top}
+table{border-collapse:collapse;border-spacing:0}
+*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
+html,body{font-size:100%}
+body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto}
+a:hover{cursor:pointer}
+img,object,embed{max-width:100%;height:auto}
+object,embed{height:100%}
+img{-ms-interpolation-mode:bicubic}
+#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none!important}
+.left{float:left!important}
+.right{float:right!important}
+.text-left{text-align:left!important}
+.text-right{text-align:right!important}
+.text-center{text-align:center!important}
+.text-justify{text-align:justify!important}
+.hide{display:none}
+.antialiased,body{-webkit-font-smoothing:antialiased}
+img{display:inline-block;vertical-align:middle}
+textarea{height:auto;min-height:50px}
+select{width:100%}
+p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6}
+.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
+div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
+a{color:#2156a5;text-decoration:underline;line-height:inherit}
+a:hover,a:focus{color:#1d4b8f}
+a img{border:none}
+p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
+p aside{font-size:.875em;line-height:1.35;font-style:italic}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
+h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
+h1{font-size:2.125em}
+h2{font-size:1.6875em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
+h4,h5{font-size:1.125em}
+h6{font-size:1em}
+hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
+em,i{font-style:italic;line-height:inherit}
+strong,b{font-weight:bold;line-height:inherit}
+small{font-size:60%;line-height:inherit}
+code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
+ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
+ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em}
+ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
+ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
+ul.square{list-style-type:square}
+ul.circle{list-style-type:circle}
+ul.disc{list-style-type:disc}
+ul.no-bullet{list-style:none}
+ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
+dl dt{margin-bottom:.3125em;font-weight:bold}
+dl dd{margin-bottom:1.25em}
+abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
+abbr{text-transform:none}
+blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
+blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
+blockquote cite:before{content:"\2014 \0020"}
+blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
+blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
+@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
+h1{font-size:2.75em}
+h2{font-size:2.3125em}
+h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
+h4{font-size:1.4375em}}table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
+table thead,table tfoot{background:#f7f8f7;font-weight:bold}
+table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
+table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
+table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
+table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
+h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
+h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
+.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table}
+.clearfix:after,.float-group:after{clear:both}
+*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
+pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
+.keyseq{color:rgba(51,51,51,.8)}
+kbd{display:inline-block;color:rgba(0,0,0,.8);font-size:.75em;line-height:1.4;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:-.15em .15em 0 .15em;padding:.2em .6em .2em .5em;vertical-align:middle;white-space:nowrap}
+.keyseq kbd:first-child{margin-left:0}
+.keyseq kbd:last-child{margin-right:0}
+.menuseq,.menu{color:rgba(0,0,0,.8)}
+b.button:before,b.button:after{position:relative;top:-1px;font-weight:400}
+b.button:before{content:"[";padding:0 3px 0 2px}
+b.button:after{content:"]";padding:0 2px 0 3px}
+p a>code:hover{color:rgba(0,0,0,.9)}
+#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
+#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table}
+#header:after,#content:after,#footnotes:after,#footer:after{clear:both}
+#content{margin-top:1.25em}
+#content:before{content:none}
+#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
+#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8}
+#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px}
+#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
+#header .details span:first-child{margin-left:-.125em}
+#header .details span.email a{color:rgba(0,0,0,.85)}
+#header .details br{display:none}
+#header .details br+span:before{content:"\00a0\2013\00a0"}
+#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
+#header .details br+span#revremark:before{content:"\00a0|\00a0"}
+#header #revnumber{text-transform:capitalize}
+#header #revnumber:after{content:"\00a0"}
+#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
+#toc{border-bottom:1px solid #efefed;padding-bottom:.5em}
+#toc>ul{margin-left:.125em}
+#toc ul.sectlevel0>li>a{font-style:italic}
+#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
+#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
+#toc a{text-decoration:none}
+#toc a:active{text-decoration:underline}
+#toctitle{color:#7a2518;font-size:1.2em}
+@media only screen and (min-width:768px){#toctitle{font-size:1.375em}
+body.toc2{padding-left:15em;padding-right:0}
+#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
+#toc.toc2 #toctitle{margin-top:0;font-size:1.2em}
+#toc.toc2>ul{font-size:.9em;margin-bottom:0}
+#toc.toc2 ul ul{margin-left:0;padding-left:1em}
+#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
+body.toc2.toc-right{padding-left:0;padding-right:15em}
+body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}}@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
+#toc.toc2{width:20em}
+#toc.toc2 #toctitle{font-size:1.375em}
+#toc.toc2>ul{font-size:.95em}
+#toc.toc2 ul ul{padding-left:1.25em}
+body.toc2.toc-right{padding-left:0;padding-right:20em}}#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
+#content #toc>:first-child{margin-top:0}
+#content #toc>:last-child{margin-bottom:0}
+#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
+#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
+.sect1{padding-bottom:.625em}
+@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}}.sect1+.sect1{border-top:1px solid #efefed}
+#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
+#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
+#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
+#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
+#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
+.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
+.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
+table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0}
+.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)}
+table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit}
+.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
+.admonitionblock>table td.icon{text-align:center;width:80px}
+.admonitionblock>table td.icon img{max-width:none}
+.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
+.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)}
+.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
+.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
+.exampleblock>.content>:first-child{margin-top:0}
+.exampleblock>.content>:last-child{margin-bottom:0}
+.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
+.sidebarblock>:first-child{margin-top:0}
+.sidebarblock>:last-child{margin-bottom:0}
+.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
+.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
+.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
+.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
+.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em}
+.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal}
+@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
+.listingblock pre.highlightjs{padding:0}
+.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
+.listingblock pre.prettyprint{border-width:0}
+.listingblock>.content{position:relative}
+.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
+.listingblock:hover code[data-lang]:before{display:block}
+.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999}
+.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"}
+table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
+table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0}
+table.pyhltable td.code{padding-left:.75em;padding-right:0}
+pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8}
+pre.pygments .lineno{display:inline-block;margin-right:.25em}
+table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
+.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
+.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
+.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
+.quoteblock blockquote{margin:0;padding:0;border:0}
+.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
+.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
+.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right}
+.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)}
+.quoteblock .quoteblock blockquote{padding:0 0 0 .75em}
+.quoteblock .quoteblock blockquote:before{display:none}
+.verseblock{margin:0 1em 1.25em 1em}
+.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
+.verseblock pre strong{font-weight:400}
+.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
+.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
+.quoteblock .attribution br,.verseblock .attribution br{display:none}
+.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.05em;color:rgba(0,0,0,.6)}
+.quoteblock.abstract{margin:0 0 1.25em 0;display:block}
+.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0}
+.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none}
+table.tableblock{max-width:100%;border-collapse:separate}
+table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0}
+table.spread{width:100%}
+table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
+table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0}
+table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0}
+table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0}
+table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0}
+table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0}
+table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0}
+table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0}
+table.frame-all{border-width:1px}
+table.frame-sides{border-width:0 1px}
+table.frame-topbot{border-width:1px 0}
+th.halign-left,td.halign-left{text-align:left}
+th.halign-right,td.halign-right{text-align:right}
+th.halign-center,td.halign-center{text-align:center}
+th.valign-top,td.valign-top{vertical-align:top}
+th.valign-bottom,td.valign-bottom{vertical-align:bottom}
+th.valign-middle,td.valign-middle{vertical-align:middle}
+table thead th,table tfoot th{font-weight:bold}
+tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
+tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
+p.tableblock>code:only-child{background:none;padding:0}
+p.tableblock{font-size:1em}
+td>div.verse{white-space:pre}
+ol{margin-left:1.75em}
+ul li ol{margin-left:1.5em}
+dl dd{margin-left:1.125em}
+dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
+ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
+ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none}
+ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em}
+ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em}
+ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px}
+ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden}
+ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block}
+ul.inline>li>*{display:block}
+.unstyled dl dt{font-weight:400;font-style:normal}
+ol.arabic{list-style-type:decimal}
+ol.decimal{list-style-type:decimal-leading-zero}
+ol.loweralpha{list-style-type:lower-alpha}
+ol.upperalpha{list-style-type:upper-alpha}
+ol.lowerroman{list-style-type:lower-roman}
+ol.upperroman{list-style-type:upper-roman}
+ol.lowergreek{list-style-type:lower-greek}
+.hdlist>table,.colist>table{border:0;background:none}
+.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
+td.hdlist1{padding-right:.75em;font-weight:bold}
+td.hdlist1,td.hdlist2{vertical-align:top}
+.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
+.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1}
+.colist>table tr>td:last-of-type{padding:.25em 0}
+.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
+.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0}
+.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em}
+.imageblock>.title{margin-bottom:0}
+.imageblock.thumb,.imageblock.th{border-width:6px}
+.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
+.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
+.image.left{margin-right:.625em}
+.image.right{margin-left:.625em}
+a.image{text-decoration:none}
+span.footnote,span.footnoteref{vertical-align:super;font-size:.875em}
+span.footnote a,span.footnoteref a{text-decoration:none}
+span.footnote a:active,span.footnoteref a:active{text-decoration:underline}
+#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
+#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0}
+#footnotes .footnote{padding:0 .375em;line-height:1.3;font-size:.875em;margin-left:1.2em;text-indent:-1.2em;margin-bottom:.2em}
+#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none}
+#footnotes .footnote:last-of-type{margin-bottom:0}
+#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
+.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
+.gist .file-data>table td.line-data{width:99%}
+div.unbreakable{page-break-inside:avoid}
+.big{font-size:larger}
+.small{font-size:smaller}
+.underline{text-decoration:underline}
+.overline{text-decoration:overline}
+.line-through{text-decoration:line-through}
+.aqua{color:#00bfbf}
+.aqua-background{background-color:#00fafa}
+.black{color:#000}
+.black-background{background-color:#000}
+.blue{color:#0000bf}
+.blue-background{background-color:#0000fa}
+.fuchsia{color:#bf00bf}
+.fuchsia-background{background-color:#fa00fa}
+.gray{color:#606060}
+.gray-background{background-color:#7d7d7d}
+.green{color:#006000}
+.green-background{background-color:#007d00}
+.lime{color:#00bf00}
+.lime-background{background-color:#00fa00}
+.maroon{color:#600000}
+.maroon-background{background-color:#7d0000}
+.navy{color:#000060}
+.navy-background{background-color:#00007d}
+.olive{color:#606000}
+.olive-background{background-color:#7d7d00}
+.purple{color:#600060}
+.purple-background{background-color:#7d007d}
+.red{color:#bf0000}
+.red-background{background-color:#fa0000}
+.silver{color:#909090}
+.silver-background{background-color:#bcbcbc}
+.teal{color:#006060}
+.teal-background{background-color:#007d7d}
+.white{color:#bfbfbf}
+.white-background{background-color:#fafafa}
+.yellow{color:#bfbf00}
+.yellow-background{background-color:#fafa00}
+span.icon>.fa{cursor:default}
+.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
+.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c}
+.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
+.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900}
+.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400}
+.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000}
+.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
+.conum[data-value] *{color:#fff!important}
+.conum[data-value]+b{display:none}
+.conum[data-value]:after{content:attr(data-value)}
+pre .conum[data-value]{position:relative;top:-.125em}
+b.conum *{color:inherit!important}
+.conum:not([data-value]):empty{display:none}
+h1,h2{letter-spacing:-.01em}
+dt,th.tableblock,td.content{text-rendering:optimizeLegibility}
+p,td.content{letter-spacing:-.01em}
+p strong,td.content strong{letter-spacing:-.005em}
+p,blockquote,dt,td.content{font-size:1.0625rem}
+p{margin-bottom:1.25rem}
+.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
+.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
+.print-only{display:none!important}
+@media print{@page{margin:1.25cm .75cm}
+*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
+a{color:inherit!important;text-decoration:underline!important}
+a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
+a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
+abbr[title]:after{content:" (" attr(title) ")"}
+pre,blockquote,tr,img{page-break-inside:avoid}
+thead{display:table-header-group}
+img{max-width:100%!important}
+p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
+h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
+#toc,.sidebarblock,.exampleblock>.content{background:none!important}
+#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important}
+.sect1{padding-bottom:0!important}
+.sect1+.sect1{border:0!important}
+#header>h1:first-child{margin-top:1.25rem}
+body.book #header{text-align:center}
+body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0}
+body.book #header .details{border:0!important;display:block;padding:0!important}
+body.book #header .details span:first-child{margin-left:0!important}
+body.book #header .details br{display:block}
+body.book #header .details br+span:before{content:none!important}
+body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
+body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
+.listingblock code[data-lang]:before{display:block}
+#footer{background:none!important;padding:0 .9375em}
+#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em}
+.hide-on-print{display:none!important}
+.print-only{display:block!important}
+.hide-for-print{display:none!important}
+.show-for-print{display:inherit!important}}
+</style>
+<style>
+.listingblock .pygments .hll { background-color: #ffffcc }
+.listingblock .pygments { background: #f8f8f8; }
+.listingblock .pygments .tok-c { color: #408080; font-style: italic } /* Comment */
+.listingblock .pygments .tok-err { border: 1px solid #FF0000 } /* Error */
+.listingblock .pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */
+.listingblock .pygments .tok-o { color: #666666 } /* Operator */
+.listingblock .pygments .tok-cm { color: #408080; font-style: italic } /* Comment.Multiline */
+.listingblock .pygments .tok-cp { color: #BC7A00 } /* Comment.Preproc */
+.listingblock .pygments .tok-c1 { color: #408080; font-style: italic } /* Comment.Single */
+.listingblock .pygments .tok-cs { color: #408080; font-style: italic } /* Comment.Special */
+.listingblock .pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
+.listingblock .pygments .tok-ge { font-style: italic } /* Generic.Emph */
+.listingblock .pygments .tok-gr { color: #FF0000 } /* Generic.Error */
+.listingblock .pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.listingblock .pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
+.listingblock .pygments .tok-go { color: #888888 } /* Generic.Output */
+.listingblock .pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.listingblock .pygments .tok-gs { font-weight: bold } /* Generic.Strong */
+.listingblock .pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.listingblock .pygments .tok-gt { color: #0044DD } /* Generic.Traceback */
+.listingblock .pygments .tok-kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.listingblock .pygments .tok-kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.listingblock .pygments .tok-kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.listingblock .pygments .tok-kp { color: #008000 } /* Keyword.Pseudo */
+.listingblock .pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.listingblock .pygments .tok-kt { color: #B00040 } /* Keyword.Type */
+.listingblock .pygments .tok-m { color: #666666 } /* Literal.Number */
+.listingblock .pygments .tok-s { color: #BA2121 } /* Literal.String */
+.listingblock .pygments .tok-na { color: #7D9029 } /* Name.Attribute */
+.listingblock .pygments .tok-nb { color: #008000 } /* Name.Builtin */
+.listingblock .pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */
+.listingblock .pygments .tok-no { color: #880000 } /* Name.Constant */
+.listingblock .pygments .tok-nd { color: #AA22FF } /* Name.Decorator */
+.listingblock .pygments .tok-ni { color: #999999; font-weight: bold } /* Name.Entity */
+.listingblock .pygments .tok-ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.listingblock .pygments .tok-nf { color: #0000FF } /* Name.Function */
+.listingblock .pygments .tok-nl { color: #A0A000 } /* Name.Label */
+.listingblock .pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.listingblock .pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */
+.listingblock .pygments .tok-nv { color: #19177C } /* Name.Variable */
+.listingblock .pygments .tok-ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.listingblock .pygments .tok-w { color: #bbbbbb } /* Text.Whitespace */
+.listingblock .pygments .tok-mb { color: #666666 } /* Literal.Number.Bin */
+.listingblock .pygments .tok-mf { color: #666666 } /* Literal.Number.Float */
+.listingblock .pygments .tok-mh { color: #666666 } /* Literal.Number.Hex */
+.listingblock .pygments .tok-mi { color: #666666 } /* Literal.Number.Integer */
+.listingblock .pygments .tok-mo { color: #666666 } /* Literal.Number.Oct */
+.listingblock .pygments .tok-sb { color: #BA2121 } /* Literal.String.Backtick */
+.listingblock .pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */
+.listingblock .pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
+.listingblock .pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */
+.listingblock .pygments .tok-se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.listingblock .pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */
+.listingblock .pygments .tok-si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.listingblock .pygments .tok-sx { color: #008000 } /* Literal.String.Other */
+.listingblock .pygments .tok-sr { color: #BB6688 } /* Literal.String.Regex */
+.listingblock .pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */
+.listingblock .pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */
+.listingblock .pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */
+.listingblock .pygments .tok-vc { color: #19177C } /* Name.Variable.Class */
+.listingblock .pygments .tok-vg { color: #19177C } /* Name.Variable.Global */
+.listingblock .pygments .tok-vi { color: #19177C } /* Name.Variable.Instance */
+.listingblock .pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
+</style>
</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<div class="article">
-<div class="section">
-<div class="titlepage"><div><div><h2 class="title" style="clear: both">
-<a name="quickstart.main"></a><a class="link" href="quickstart.html#quickstart.main" title="pugixml 1.5 quick start guide"> pugixml 1.5 quick start guide</a>
-</h2></div></div></div>
-<div class="toc"><dl class="toc">
-<dt><span class="section"><a href="quickstart.html#quickstart.main.introduction"> Introduction</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.install"> Installation</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.dom"> Document object model</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.loading"> Loading document</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.access"> Accessing document data</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.modify"> Modifying document data</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.saving"> Saving document</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.feedback"> Feedback</a></span></dt>
-<dt><span class="section"><a href="quickstart.html#quickstart.main.license"> License</a></span></dt>
-</dl></div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.introduction"></a><a class="link" href="quickstart.html#quickstart.main.introduction" title="Introduction"> Introduction</a>
-</h3></div></div></div>
-<p>
- <a href="http://pugixml.org/" target="_top">pugixml</a> is a light-weight C++ XML
- processing library. It consists of a DOM-like interface with rich traversal/modification
- capabilities, an extremely fast XML parser which constructs the DOM tree
- from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven
- tree queries. Full Unicode support is also available, with Unicode interface
- variants and conversions between different Unicode encodings (which happen
- automatically during parsing/saving). The library is extremely portable and
- easy to integrate and use. pugixml is developed and maintained since 2006
- and has many users. All code is distributed under the <a class="link" href="quickstart.html#quickstart.main.license" title="License">MIT
- license</a>, making it completely free to use in both open-source and
- proprietary applications.
- </p>
-<p>
- pugixml enables very fast, convenient and memory-efficient XML document processing.
- However, since pugixml has a DOM parser, it can't process XML documents that
- do not fit in memory; also the parser is a non-validating one, so if you
- need DTD/Schema validation, the library is not for you.
- </p>
-<p>
- This is the quick start guide for pugixml, which purpose is to enable you
- to start using the library quickly. Many important library features are either
- not described at all or only mentioned briefly; for more complete information
- you <a href="manual.html" target="_top">should read the complete manual</a>.
- </p>
-<div class="note"><table border="0" summary="Note">
+<body class="article toc2 toc-right">
+<div id="header">
+<h1>pugixml 1.6 quick start guide</h1>
+<div class="details">
+<span id="author" class="author">website</span><br>
+<span id="email" class="email"><a href="http://pugixml.org" class="bare">http://pugixml.org</a></span><br>
+<span id="author2" class="author">repository</span><br>
+<span id="email2" class="email"><a href="http://github.com/zeux/pugixml" class="bare">http://github.com/zeux/pugixml</a></span><br>
+</div>
+<div id="toc" class="toc2">
+<div id="toctitle">Table of Contents</div>
+<ul class="sectlevel1">
+<li><a href="#introduction">Introduction</a></li>
+<li><a href="#install">Installation</a></li>
+<li><a href="#dom">Document object model</a></li>
+<li><a href="#loading">Loading document</a></li>
+<li><a href="#access">Accessing document data</a></li>
+<li><a href="#modify">Modifying document data</a></li>
+<li><a href="#saving">Saving document</a></li>
+<li><a href="#feedback">Feedback</a></li>
+<li><a href="#license">License</a></li>
+</ul>
+</div>
+</div>
+<div id="content">
+<div class="sect1">
+<h2 id="introduction"><a class="anchor" href="#introduction"></a>Introduction</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p><a href="http://pugixml.org/">pugixml</a> is a light-weight C&#43;&#43; XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with two Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is extremely portable and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the <a href="#license">MIT license</a>, making it completely free to use in both open-source and proprietary applications.</p>
+</div>
+<div class="paragraph">
+<p>pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can&#8217;t process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD/Schema validation, the library is not for you.</p>
+</div>
+<div class="paragraph">
+<p>This is the quick start guide for pugixml, which purpose is to enable you to start using the library quickly. Many important library features are either not described at all or only mentioned briefly; for more complete information you <a href="manual.html">should read the complete manual</a>.</p>
+</div>
+<div class="admonitionblock note">
+<table>
<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
-<th align="left">Note</th>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to <a href="https://github.com/zeux/pugixml/issues/new">submit an issue or open a pull request</a> with a fix.
+</td>
</tr>
-<tr><td align="left" valign="top"><p>
- No documentation is perfect, neither is this one. If you encounter a description
- that is unclear, please file an issue as described in <a class="xref" href="quickstart.html#quickstart.main.feedback" title="Feedback"> Feedback</a>. Also if
- you can spare the time for a full proof-reading, including spelling and
- grammar, that would be great! Please <a class="link" href="quickstart.html#email">send me an e-mail</a>;
- as a token of appreciation, your name will be included into the corresponding
- section of the manual.
- </p></td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.install"></a><a class="link" href="quickstart.html#quickstart.main.install" title="Installation"> Installation</a>
-</h3></div></div></div>
-<p>
- pugixml is distributed in source form. You can download a source distribution
- via one of the following links:
- </p>
-<pre class="programlisting"><a href="https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.zip" target="_top">https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.zip</a>
-<a href="https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.tar.gz" target="_top">https://github.com/zeux/pugixml/releases/download/v1.5/pugixml-1.5.tar.gz</a>
-</pre>
-<p>
- The distribution contains library source, documentation (the guide you're
- reading now and the manual) and some code examples. After downloading the
- distribution, install pugixml by extracting all files from the compressed
- archive. The files have different line endings depending on the archive format
- - <code class="filename">.zip</code> archive has Windows line endings, <code class="filename">.tar.gz</code> archive has Unix line endings.
- Otherwise the files in both archives are identical.
- </p>
-<p>
- The complete pugixml source consists of three files - one source file, <code class="filename">pugixml.cpp</code>,
- and two header files, <code class="filename">pugixml.hpp</code> and <code class="filename">pugiconfig.hpp</code>. <code class="filename">pugixml.hpp</code> is the primary
- header which you need to include in order to use pugixml classes/functions.
- The rest of this guide assumes that <code class="filename">pugixml.hpp</code> is either in the current directory
- or in one of include directories of your projects, so that <code class="computeroutput"><span class="preprocessor">#include</span> <span class="string">"pugixml.hpp"</span></code>
- can find the header; however you can also use relative path (i.e. <code class="computeroutput"><span class="preprocessor">#include</span> <span class="string">"../libs/pugixml/src/pugixml.hpp"</span></code>)
- or include directory-relative path (i.e. <code class="computeroutput"><span class="preprocessor">#include</span>
- <span class="special">&lt;</span><span class="identifier">xml</span><span class="special">/</span><span class="identifier">thirdparty</span><span class="special">/</span><span class="identifier">pugixml</span><span class="special">/</span><span class="identifier">src</span><span class="special">/</span><span class="identifier">pugixml</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>).
- </p>
-<p>
- The easiest way to build pugixml is to compile the source file, <code class="filename">pugixml.cpp</code>,
- along with the existing library/executable. This process depends on the method
- of building your application; for example, if you're using Microsoft Visual
- Studio<a href="#ftn.trademarks" class="footnote" name="trademarks"><sup class="footnote">[1]</sup></a>,
- Apple Xcode, Code::Blocks or any other IDE, just add <code class="filename">pugixml.cpp</code> to one of
- your projects. There are other building methods available, including building
- pugixml as a standalone static/shared library; <a href="manual/install.html#manual.install.building" target="_top">read
- the manual</a> for further information.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.dom"></a><a class="link" href="quickstart.html#quickstart.main.dom" title="Document object model"> Document object model</a>
-</h3></div></div></div>
-<p>
- pugixml stores XML data in DOM-like way: the entire XML document (both document
- structure and element data) is stored in memory as a tree. The tree can be
- loaded from character stream (file, string, C++ I/O stream), then traversed
- via special API or XPath expressions. The whole tree is mutable: both node
- structure and node/attribute data can be changed at any time. Finally, the
- result of document transformations can be saved to a character stream (file,
- C++ I/O stream or custom transport).
- </p>
-<p>
- The root of the tree is the document itself, which corresponds to C++ type
- <code class="computeroutput"><span class="identifier">xml_document</span></code>. Document has
- one or more child nodes, which correspond to C++ type <code class="computeroutput"><span class="identifier">xml_node</span></code>.
- Nodes have different types; depending on a type, a node can have a collection
- of child nodes, a collection of attributes, which correspond to C++ type
- <code class="computeroutput"><span class="identifier">xml_attribute</span></code>, and some additional
- data (i.e. name).
- </p>
-<p>
- The most common node types are:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- Document node (<code class="computeroutput"><span class="identifier">node_document</span></code>)
- - this is the root of the tree, which consists of several child nodes.
- This node corresponds to <code class="computeroutput"><span class="identifier">xml_document</span></code>
- class; note that <code class="computeroutput"><span class="identifier">xml_document</span></code>
- is a sub-class of <code class="computeroutput"><span class="identifier">xml_node</span></code>,
- so the entire node interface is also available.
- </li>
-<li class="listitem">
- Element/tag node (<code class="computeroutput"><span class="identifier">node_element</span></code>)
- - this is the most common type of node, which represents XML elements.
- Element nodes have a name, a collection of attributes and a collection
- of child nodes (both of which may be empty). The attribute is a simple
- name/value pair.
- </li>
-<li class="listitem">
- Plain character data nodes (<code class="computeroutput"><span class="identifier">node_pcdata</span></code>)
- represent plain text in XML. PCDATA nodes have a value, but do not have
- name or children/attributes. Note that <span class="bold"><strong>plain character
- data is not a part of the element node but instead has its own node</strong></span>;
- for example, an element node can have several child PCDATA nodes.
- </li>
-</ul></div>
-<p>
- Despite the fact that there are several node types, there are only three
- C++ types representing the tree (<code class="computeroutput"><span class="identifier">xml_document</span></code>,
- <code class="computeroutput"><span class="identifier">xml_node</span></code>, <code class="computeroutput"><span class="identifier">xml_attribute</span></code>);
- some operations on <code class="computeroutput"><span class="identifier">xml_node</span></code>
- are only valid for certain node types. They are described below.
- </p>
-<div class="note"><table border="0" summary="Note">
+</table>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="install"><a class="anchor" href="#install"></a>Installation</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>You can download the latest source distribution as an archive:</p>
+</div>
+<div class="paragraph">
+<p><a href="https://github.com/zeux/pugixml/releases/download/v1.6/pugixml-1.6.zip">pugixml-1.6.zip</a> (Windows line endings)
+/
+<a href="https://github.com/zeux/pugixml/releases/download/v1.6/pugixml-1.6.tar.gz">pugixml-1.6.tar.gz</a> (Unix line endings)</p>
+</div>
+<div class="paragraph">
+<p>The distribution contains library source, documentation (the guide you&#8217;re reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.</p>
+</div>
+<div class="paragraph">
+<p>The complete pugixml source consists of three files - one source file, <code>pugixml.cpp</code>, and two header files, <code>pugixml.hpp</code> and <code>pugiconfig.hpp</code>. <code>pugixml.hpp</code> is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that <code>pugixml.hpp</code> is either in the current directory or in one of include directories of your projects, so that <code>#include "pugixml.hpp"</code> can find the header; however you can also use relative path (i.e. <code>#include "../libs/pugixml/src/pugixml.hpp"</code>) or include directory-relative path (i.e. <code>#include &lt;xml/thirdparty/pugixml/src/pugixml.hpp&gt;</code>).</p>
+</div>
+<div class="paragraph">
+<p>The easiest way to build pugixml is to compile the source file, <code>pugixml.cpp</code>, along with the existing library/executable. This process depends on the method of building your application; for example, if you&#8217;re using Microsoft Visual Studio <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>, Apple Xcode, Code::Blocks or any other IDE, just add <code>pugixml.cpp</code> to one of your projects. There are other building methods available, including building pugixml as a standalone static/shared library; <a href="manual/install.html#install.building">read the manual</a> for further information.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="dom"><a class="anchor" href="#dom"></a>Document object model</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from character stream (file, string, C&#43;&#43; I/O stream), then traversed via special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C&#43;&#43; I/O stream or custom transport).</p>
+</div>
+<div class="paragraph">
+<p>The root of the tree is the document itself, which corresponds to C&#43;&#43; type <code>xml_document</code>. Document has one or more child nodes, which correspond to C&#43;&#43; type <code>xml_node</code>. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C&#43;&#43; type <code>xml_attribute</code>, and some additional data (i.e. name).</p>
+</div>
+<div class="paragraph">
+<p>The most common node types are:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>Document node (<code>node_document</code>) - this is the root of the tree, which consists of several child nodes. This node corresponds to <code>xml_document</code> class; note that <code>xml_document</code> is a sub-class of <code>xml_node</code>, so the entire node interface is also available.</p>
+</li>
+<li>
+<p>Element/tag node (<code>node_element</code>) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair.</p>
+</li>
+<li>
+<p>Plain character data nodes (<code>node_pcdata</code>) represent plain text in XML. PCDATA nodes have a value, but do not have name or children/attributes. Note that <strong>plain character data is not a part of the element node but instead has its own node</strong>; for example, an element node can have several child PCDATA nodes.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>Despite the fact that there are several node types, there are only three C&#43;&#43; types representing the tree (<code>xml_document</code>, <code>xml_node</code>, <code>xml_attribute</code>); some operations on <code>xml_node</code> are only valid for certain node types. They are described below.</p>
+</div>
+<div class="admonitionblock note">
+<table>
<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
-<th align="left">Note</th>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+All pugixml classes and functions are located in <code>pugi</code> namespace; you have to either use explicit name qualification (i.e. <code>pugi::xml_node</code>), or to gain access to relevant symbols via <code>using</code> directive (i.e. <code>using pugi::xml_node;</code> or <code>using namespace pugi;</code>).
+</td>
</tr>
-<tr><td align="left" valign="top"><p>
- All pugixml classes and functions are located in <code class="computeroutput"><span class="identifier">pugi</span></code>
- namespace; you have to either use explicit name qualification (i.e. <code class="computeroutput"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span></code>), or to gain access to relevant
- symbols via <code class="computeroutput"><span class="keyword">using</span></code> directive
- (i.e. <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">;</span></code> or <code class="computeroutput"><span class="keyword">using</span>
- <span class="keyword">namespace</span> <span class="identifier">pugi</span><span class="special">;</span></code>).
- </p></td></tr>
-</table></div>
-<p>
- <code class="computeroutput"><span class="identifier">xml_document</span></code> is the owner
- of the entire document structure; destroying the document destroys the whole
- tree. The interface of <code class="computeroutput"><span class="identifier">xml_document</span></code>
- consists of loading functions, saving functions and the entire interface
- of <code class="computeroutput"><span class="identifier">xml_node</span></code>, which allows
- for document inspection and/or modification. Note that while <code class="computeroutput"><span class="identifier">xml_document</span></code> is a sub-class of <code class="computeroutput"><span class="identifier">xml_node</span></code>, <code class="computeroutput"><span class="identifier">xml_node</span></code>
- is not a polymorphic type; the inheritance is present only to simplify usage.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">xml_node</span></code> is the handle to
- document node; it can point to any node in the document, including document
- itself. There is a common interface for nodes of all types. Note that <code class="computeroutput"><span class="identifier">xml_node</span></code> is only a handle to the actual
- node, not the node itself - you can have several <code class="computeroutput"><span class="identifier">xml_node</span></code>
- handles pointing to the same underlying object. Destroying <code class="computeroutput"><span class="identifier">xml_node</span></code> handle does not destroy the node
- and does not remove it from the tree.
- </p>
-<p>
- There is a special value of <code class="computeroutput"><span class="identifier">xml_node</span></code>
- type, known as null node or empty node. It does not correspond to any node
- in any document, and thus resembles null pointer. However, all operations
- are defined on empty nodes; generally the operations don't do anything and
- return empty nodes/attributes or empty strings as their result. This is useful
- for chaining calls; i.e. you can get the grandparent of a node like so:
- <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">parent</span><span class="special">().</span><span class="identifier">parent</span><span class="special">()</span></code>;
- if a node is a null node or it does not have a parent, the first <code class="computeroutput"><span class="identifier">parent</span><span class="special">()</span></code>
- call returns null node; the second <code class="computeroutput"><span class="identifier">parent</span><span class="special">()</span></code> call then also returns null node, so you
- don't have to check for errors twice. You can test if a handle is null via
- implicit boolean cast: <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>
- or <code class="computeroutput"><span class="keyword">if</span> <span class="special">(!</span><span class="identifier">node</span><span class="special">)</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">xml_attribute</span></code> is the handle
- to an XML attribute; it has the same semantics as <code class="computeroutput"><span class="identifier">xml_node</span></code>,
- i.e. there can be several <code class="computeroutput"><span class="identifier">xml_attribute</span></code>
- handles pointing to the same underlying object and there is a special null
- attribute value, which propagates to function results.
- </p>
-<p>
- There are two choices of interface and internal representation when configuring
- pugixml: you can either choose the UTF-8 (also called char) interface or
- UTF-16/32 (also called wchar_t) one. The choice is controlled via <code class="computeroutput"><span class="identifier">PUGIXML_WCHAR_MODE</span></code> define; you can set
- it via <code class="filename">pugiconfig.hpp</code> or via preprocessor options. All tree functions that
- work with strings work with either C-style null terminated strings or STL
- strings of the selected character type. <a href="manual/dom.html#manual.dom.unicode" target="_top">Read
- the manual</a> for additional information on Unicode interface.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.loading"></a><a class="link" href="quickstart.html#quickstart.main.loading" title="Loading document"> Loading document</a>
-</h3></div></div></div>
-<p>
- pugixml provides several functions for loading XML data from various places
- - files, C++ iostreams, memory buffers. All functions use an extremely fast
- non-validating parser. This parser is not fully W3C conformant - it can load
- any valid XML document, but does not perform some well-formedness checks.
- While considerable effort is made to reject invalid XML documents, some validation
- is not performed because of performance reasons. XML data is always converted
- to internal character format before parsing. pugixml supports all popular
- Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and
- little endian); UCS-2 is naturally supported since it's a strict subset of
- UTF-16) and handles all encoding conversions automatically.
- </p>
-<p>
- The most common source of XML data is files; pugixml provides a separate
- function for loading XML document from file. This function accepts file path
- as its first argument, and also two optional arguments, which specify parsing
- options and input data encoding, which are described in the manual.
- </p>
-<p>
- This is an example of loading XML document from file (<a href="samples/load_file.cpp" target="_top">samples/load_file.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="string">"tree.xml"</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Load result: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">description</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">", mesh name: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"mesh"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">load_file</span></code>, as well as other
- loading functions, destroys the existing document tree and then tries to
- load the new tree from the specified file. The result of the operation is
- returned in an <code class="computeroutput"><span class="identifier">xml_parse_result</span></code>
- object; this object contains the operation status, and the related information
- (i.e. last successfully parsed position in the input file, if parsing fails).
- </p>
-<p>
- Parsing result object can be implicitly converted to <code class="computeroutput"><span class="keyword">bool</span></code>;
- if you do not want to handle parsing errors thoroughly, you can just check
- the return value of load functions as if it was a <code class="computeroutput"><span class="keyword">bool</span></code>:
- <code class="computeroutput"><span class="keyword">if</span> <span class="special">(</span><span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_file</span><span class="special">(</span><span class="string">"file.xml"</span><span class="special">))</span> <span class="special">{</span> <span class="special">...</span>
- <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>.
- Otherwise you can use the <code class="computeroutput"><span class="identifier">status</span></code>
- member to get parsing status, or the <code class="computeroutput"><span class="identifier">description</span><span class="special">()</span></code> member function to get the status in a
- string form.
- </p>
-<p>
- This is an example of handling loading errors (<a href="samples/load_error_handling.cpp" target="_top">samples/load_error_handling.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_document</span> <span class="identifier">doc</span><span class="special">;</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_string</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span>
-
-<span class="keyword">if</span> <span class="special">(</span><span class="identifier">result</span><span class="special">)</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"XML ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">source</span> <span class="special">&lt;&lt;</span> <span class="string">"] parsed without errors, attr value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"attr"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n\n"</span><span class="special">;</span>
-<span class="keyword">else</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"XML ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">source</span> <span class="special">&lt;&lt;</span> <span class="string">"] parsed with errors, attr value: ["</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"attr"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n"</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Error description: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">description</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Error offset: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">offset</span> <span class="special">&lt;&lt;</span> <span class="string">" (error at [..."</span> <span class="special">&lt;&lt;</span> <span class="special">(</span><span class="identifier">source</span> <span class="special">+</span> <span class="identifier">result</span><span class="special">.</span><span class="identifier">offset</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"]\n\n"</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<p>
- Sometimes XML data should be loaded from some other source than file, i.e.
- HTTP URL; also you may want to load XML data from file using non-standard
- functions, i.e. to use your virtual file system facilities or to load XML
- from gzip-compressed files. These scenarios either require loading document
- from memory, in which case you should prepare a contiguous memory block with
- all XML data and to pass it to one of buffer loading functions, or loading
- document from C++ IOstream, in which case you should provide an object which
- implements <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">wistream</span></code>
- interface.
- </p>
-<p>
- There are different functions for loading document from memory; they treat
- the passed buffer as either an immutable one (<code class="computeroutput"><span class="identifier">load_buffer</span></code>),
- a mutable buffer which is owned by the caller (<code class="computeroutput"><span class="identifier">load_buffer_inplace</span></code>),
- or a mutable buffer which ownership belongs to pugixml (<code class="computeroutput"><span class="identifier">load_buffer_inplace_own</span></code>).
- There is also a simple helper function, <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">load</span></code>,
- for cases when you want to load the XML document from null-terminated character
- string.
- </p>
-<p>
- This is an example of loading XML document from memory using one of these
- functions (<a href="samples/load_memory.cpp" target="_top">samples/load_memory.cpp</a>);
- read the sample code for more examples:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="keyword">char</span> <span class="identifier">source</span><span class="special">[]</span> <span class="special">=</span> <span class="string">"&lt;mesh name='sphere'&gt;&lt;bounds&gt;0 0 1 1&lt;/bounds&gt;&lt;/mesh&gt;"</span><span class="special">;</span>
-<span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">source</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document
-</span><span class="keyword">char</span><span class="special">*</span> <span class="identifier">buffer</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">char</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span>
-<span class="identifier">memcpy</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">source</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-
-<span class="comment">// The block can be allocated by any method; the block is modified during parsing
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load_buffer_inplace</span><span class="special">(</span><span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">size</span><span class="special">);</span>
-
-<span class="comment">// You have to destroy the block yourself after the document is no longer used
-</span><span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">buffer</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- This is a simple example of loading XML document from file using streams
- (<a href="samples/load_stream.cpp" target="_top">samples/load_stream.cpp</a>); read
- the sample code for more complex examples involving wide streams and locales:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ifstream</span> <span class="identifier">stream</span><span class="special">(</span><span class="string">"weekly-utf-8.xml"</span><span class="special">);</span>
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_parse_result</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">load</span><span class="special">(</span><span class="identifier">stream</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.access"></a><a class="link" href="quickstart.html#quickstart.main.access" title="Accessing document data"> Accessing document data</a>
-</h3></div></div></div>
-<p>
- pugixml features an extensive interface for getting various types of data
- from the document and for traversing the document. You can use various accessors
- to get node/attribute data, you can traverse the child node/attribute lists
- via accessors or iterators, you can do depth-first traversals with <code class="computeroutput"><span class="identifier">xml_tree_walker</span></code> objects, and you can use
- XPath for complex data-driven queries.
- </p>
-<p>
- You can get node or attribute name via <code class="computeroutput"><span class="identifier">name</span><span class="special">()</span></code> accessor, and value via <code class="computeroutput"><span class="identifier">value</span><span class="special">()</span></code> accessor. Note that both functions never
- return null pointers - they either return a string with the relevant content,
- or an empty string if name/value is absent or if the handle is null. Also
- there are two notable things for reading values:
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
-<li class="listitem">
- It is common to store data as text contents of some node - i.e. <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">node</span><span class="special">&gt;&lt;</span><span class="identifier">description</span><span class="special">&gt;</span><span class="identifier">This</span>
- <span class="identifier">is</span> <span class="identifier">a</span>
- <span class="identifier">node</span><span class="special">&lt;/</span><span class="identifier">description</span><span class="special">&gt;&lt;/</span><span class="identifier">node</span><span class="special">&gt;</span></code>.
- In this case, <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">description</span><span class="special">&gt;</span></code> node does not have a value, but instead
- has a child of type <code class="computeroutput"><span class="identifier">node_pcdata</span></code>
- with value <code class="computeroutput"><span class="string">"This is a node"</span></code>.
- pugixml provides <code class="computeroutput"><span class="identifier">child_value</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">text</span><span class="special">()</span></code> helper functions to parse such data.
- </li>
-<li class="listitem">
- In many cases attribute values have types that are not strings - i.e.
- an attribute may always contain values that should be treated as integers,
- despite the fact that they are represented as strings in XML. pugixml
- provides several accessors that convert attribute value to some other
- type.
- </li>
-</ul></div>
-<p>
- This is an example of using these functions (<a href="samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">": AllowRemote "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"AllowRemote"</span><span class="special">).</span><span class="identifier">as_bool</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", Timeout "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Timeout"</span><span class="special">).</span><span class="identifier">as_int</span><span class="special">();</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", Description '"</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">child_value</span><span class="special">(</span><span class="string">"Description"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"'\n"</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<p>
- Since a lot of document traversal consists of finding the node/attribute
- with the correct name, there are special functions for that purpose. For
- example, <code class="computeroutput"><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">)</span></code>
- returns the first node which has the name <code class="computeroutput"><span class="string">"Tool"</span></code>,
- or null handle if there is no such node. This is an example of using such
- functions (<a href="samples/traverse_base.cpp" target="_top">samples/traverse_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool for *.dae generation: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">find_child_by_attribute</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">,</span> <span class="string">"OutputFileMasks"</span><span class="special">,</span> <span class="string">"*.dae"</span><span class="special">).</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-
-<span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">);</span> <span class="identifier">tool</span><span class="special">;</span> <span class="identifier">tool</span> <span class="special">=</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">next_sibling</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool "</span> <span class="special">&lt;&lt;</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<p>
- Child node lists and attribute lists are simply double-linked lists; while
- you can use <code class="computeroutput"><span class="identifier">previous_sibling</span></code>/<code class="computeroutput"><span class="identifier">next_sibling</span></code> and other such functions for
- iteration, pugixml additionally provides node and attribute iterators, so
- that you can treat nodes as containers of other nodes or attributes. All
- iterators are bidirectional and support all usual iterator operations. The
- iterators are invalidated if the node/attribute objects they're pointing
- to are removed from the tree; adding nodes/attributes does not invalidate
- any iterators.
- </p>
-<p>
- Here is an example of using iterators for document traversal (<a href="samples/traverse_iter.cpp" target="_top">samples/traverse_iter.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool:"</span><span class="special">;</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute_iterator</span> <span class="identifier">ait</span> <span class="special">=</span> <span class="identifier">it</span><span class="special">-&gt;</span><span class="identifier">attributes_begin</span><span class="special">();</span> <span class="identifier">ait</span> <span class="special">!=</span> <span class="identifier">it</span><span class="special">-&gt;</span><span class="identifier">attributes_end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">ait</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span> <span class="special">&lt;&lt;</span> <span class="identifier">ait</span><span class="special">-&gt;</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">ait</span><span class="special">-&gt;</span><span class="identifier">value</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<p>
- If your C++ compiler supports range-based for-loop (this is a C++11 feature,
- at the time of writing it's supported by Microsoft Visual Studio 11 Beta,
- GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional
- helpers are provided to support this; note that they are also compatible
- with <a href="http://www.boost.org/libs/foreach/" target="_top">Boost Foreach</a>,
- and possibly other pre-C++11 foreach facilities.
- </p>
-<p>
- Here is an example of using C++11 range-based for loop for document traversal
- (<a href="samples/traverse_rangefor.cpp" target="_top">samples/traverse_rangefor.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">tool</span><span class="special">:</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">children</span><span class="special">(</span><span class="string">"Tool"</span><span class="special">))</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tool:"</span><span class="special">;</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span><span class="special">:</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">attributes</span><span class="special">())</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">child</span><span class="special">:</span> <span class="identifier">tool</span><span class="special">.</span><span class="identifier">children</span><span class="special">())</span>
- <span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", child "</span> <span class="special">&lt;&lt;</span> <span class="identifier">child</span><span class="special">.</span><span class="identifier">name</span><span class="special">();</span>
- <span class="special">}</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
- </p>
-<p>
- The methods described above allow traversal of immediate children of some
- node; if you want to do a deep tree traversal, you'll have to do it via a
- recursive function or some equivalent method. However, pugixml provides a
- helper for depth-first traversal of a subtree. In order to use it, you have
- to implement <code class="computeroutput"><span class="identifier">xml_tree_walker</span></code>
- interface and to call <code class="computeroutput"><span class="identifier">traverse</span></code>
- function.
- </p>
-<p>
- This is an example of traversing tree hierarchy with xml_tree_walker (<a href="samples/traverse_walker.cpp" target="_top">samples/traverse_walker.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">simple_walker</span><span class="special">:</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_tree_walker</span>
-<span class="special">{</span>
- <span class="keyword">virtual</span> <span class="keyword">bool</span> <span class="identifier">for_each</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">node</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">depth</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">" "</span><span class="special">;</span> <span class="comment">// indentation
-</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node_types</span><span class="special">[</span><span class="identifier">node</span><span class="special">.</span><span class="identifier">type</span><span class="special">()]</span> <span class="special">&lt;&lt;</span> <span class="string">": name='"</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"', value='"</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"'\n"</span><span class="special">;</span>
-
- <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span> <span class="comment">// continue traversal
-</span> <span class="special">}</span>
-<span class="special">};</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">simple_walker</span> <span class="identifier">walker</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">traverse</span><span class="special">(</span><span class="identifier">walker</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
- Finally, for complex queries often a higher-level DSL is needed. pugixml
- provides an implementation of XPath 1.0 language for such queries. The complete
- description of XPath usage can be found in the manual, but here are some
- examples:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span> <span class="identifier">tools</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_nodes</span><span class="special">(</span><span class="string">"/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Tools:\n"</span><span class="special">;</span>
-
-<span class="keyword">for</span> <span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node_set</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">tools</span><span class="special">.</span><span class="identifier">end</span><span class="special">();</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span>
-<span class="special">{</span>
- <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="special">*</span><span class="identifier">it</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-<span class="special">}</span>
-
-<span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xpath_node</span> <span class="identifier">build_tool</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">select_node</span><span class="special">(</span><span class="string">"//Tool[contains(Description, 'build system')]"</span><span class="special">);</span>
-
-<span class="keyword">if</span> <span class="special">(</span><span class="identifier">build_tool</span><span class="special">)</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Build tool: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">build_tool</span><span class="special">.</span><span class="identifier">node</span><span class="special">().</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"Filename"</span><span class="special">).</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<div class="caution"><table border="0" summary="Caution">
+</table>
+</div>
+<div class="paragraph">
+<p><code>xml_document</code> is the owner of the entire document structure; destroying the document destroys the whole tree. The interface of <code>xml_document</code> consists of loading functions, saving functions and the entire interface of <code>xml_node</code>, which allows for document inspection and/or modification. Note that while <code>xml_document</code> is a sub-class of <code>xml_node</code>, <code>xml_node</code> is not a polymorphic type; the inheritance is present only to simplify usage.</p>
+</div>
+<div class="paragraph">
+<p><code>xml_node</code> is the handle to document node; it can point to any node in the document, including document itself. There is a common interface for nodes of all types. Note that <code>xml_node</code> is only a handle to the actual node, not the node itself - you can have several <code>xml_node</code> handles pointing to the same underlying object. Destroying <code>xml_node</code> handle does not destroy the node and does not remove it from the tree.</p>
+</div>
+<div class="paragraph">
+<p>There is a special value of <code>xml_node</code> type, known as null node or empty node. It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don&#8217;t do anything and return empty nodes/attributes or empty strings as their result. This is useful for chaining calls; i.e. you can get the grandparent of a node like so: <code>node.parent().parent()</code>; if a node is a null node or it does not have a parent, the first <code>parent()</code> call returns null node; the second <code>parent()</code> call then also returns null node, so you don&#8217;t have to check for errors twice. You can test if a handle is null via implicit boolean cast: <code>if (node) { &#8230;&#8203; }</code> or <code>if (!node) { &#8230;&#8203; }</code>.</p>
+</div>
+<div class="paragraph">
+<p><code>xml_attribute</code> is the handle to an XML attribute; it has the same semantics as <code>xml_node</code>, i.e. there can be several <code>xml_attribute</code> handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.</p>
+</div>
+<div class="paragraph">
+<p>There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via <code>PUGIXML_WCHAR_MODE</code> define; you can set it via <code>pugiconfig.hpp</code> or via preprocessor options. All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. <a href="manual/dom.html#dom.unicode">Read the manual</a> for additional information on Unicode interface.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="loading"><a class="anchor" href="#loading"></a>Loading document</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>pugixml provides several functions for loading XML data from various places - files, C&#43;&#43; iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons. XML data is always converted to internal character format before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it&#8217;s a strict subset of UTF-16) and handles all encoding conversions automatically.</p>
+</div>
+<div class="paragraph">
+<p>The most common source of XML data is files; pugixml provides a separate function for loading XML document from file. This function accepts file path as its first argument, and also two optional arguments, which specify parsing options and input data encoding, which are described in the manual.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of loading XML document from file (<a href="samples/load_file.cpp" class="bare">samples/load_file.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_file</span><span class="tok-p">(</span><span class="tok-s">&quot;tree.xml&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Load result: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, mesh name: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;mesh&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p><code>load_file</code>, as well as other loading functions, destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an <code>xml_parse_result</code> object; this object contains the operation status, and the related information (i.e. last successfully parsed position in the input file, if parsing fails).</p>
+</div>
+<div class="paragraph">
+<p>Parsing result object can be implicitly converted to <code>bool</code>; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a <code>bool</code>: <code>if (doc.load_file("file.xml")) { &#8230;&#8203; } else { &#8230;&#8203; }</code>. Otherwise you can use the <code>status</code> member to get parsing status, or the <code>description()</code> member function to get the status in a string form.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of handling loading errors (<a href="samples/load_error_handling.cpp" class="bare">samples/load_error_handling.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_document</span> <span class="tok-n">doc</span><span class="tok-p">;</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_string</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span>
+
+<span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-n">result</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;XML [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">source</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;] parsed without errors, attr value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;attr&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+<span class="tok-k">else</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;XML [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">source</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;] parsed with errors, attr value: [&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;attr&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Error description: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">description</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Error offset: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; (error at [...&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-p">(</span><span class="tok-n">source</span> <span class="tok-o">+</span> <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">offset</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;]</span><span class="tok-se">\n\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C&#43;&#43; IOstream, in which case you should provide an object which implements <code>std::istream</code> or <code>std::wistream</code> interface.</p>
+</div>
+<div class="paragraph">
+<p>There are different functions for loading document from memory; they treat the passed buffer as either an immutable one (<code>load_buffer</code>), a mutable buffer which is owned by the caller (<code>load_buffer_inplace</code>), or a mutable buffer which ownership belongs to pugixml (<code>load_buffer_inplace_own</code>). There is also a simple helper function, <code>xml_document::load</code>, for cases when you want to load the XML document from null-terminated character string.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of loading XML document from memory using one of these functions (<a href="samples/load_memory.cpp" class="bare">samples/load_memory.cpp</a>); read the sample code for more examples:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">const</span> <span class="tok-kt">char</span> <span class="tok-n">source</span><span class="tok-p">[]</span> <span class="tok-o">=</span> <span class="tok-s">&quot;&lt;mesh name=&#39;sphere&#39;&gt;&lt;bounds&gt;0 0 1 1&lt;/bounds&gt;&lt;/mesh&gt;&quot;</span><span class="tok-p">;</span>
+<span class="tok-kt">size_t</span> <span class="tok-n">size</span> <span class="tok-o">=</span> <span class="tok-k">sizeof</span><span class="tok-p">(</span><span class="tok-n">source</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// You can use load_buffer_inplace to load document from mutable memory block; the block&#39;s lifetime must exceed that of document</span>
+<span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">buffer</span> <span class="tok-o">=</span> <span class="tok-k">new</span> <span class="tok-kt">char</span><span class="tok-p">[</span><span class="tok-n">size</span><span class="tok-p">];</span>
+<span class="tok-n">memcpy</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">source</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// The block can be allocated by any method; the block is modified during parsing</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load_buffer_inplace</span><span class="tok-p">(</span><span class="tok-n">buffer</span><span class="tok-p">,</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// You have to destroy the block yourself after the document is no longer used</span>
+<span class="tok-k">delete</span><span class="tok-p">[]</span> <span class="tok-n">buffer</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This is a simple example of loading XML document from file using streams (<a href="samples/load_stream.cpp" class="bare">samples/load_stream.cpp</a>); read the sample code for more complex examples involving wide streams and locales:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">ifstream</span> <span class="tok-n">stream</span><span class="tok-p">(</span><span class="tok-s">&quot;weekly-utf-8.xml&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_parse_result</span> <span class="tok-n">result</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">load</span><span class="tok-p">(</span><span class="tok-n">stream</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="access"><a class="anchor" href="#access"></a>Accessing document data</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>pugixml features an extensive interface for getting various types of data from the document and for traversing the document. You can use various accessors to get node/attribute data, you can traverse the child node/attribute lists via accessors or iterators, you can do depth-first traversals with <code>xml_tree_walker</code> objects, and you can use XPath for complex data-driven queries.</p>
+</div>
+<div class="paragraph">
+<p>You can get node or attribute name via <code>name()</code> accessor, and value via <code>value()</code> accessor. Note that both functions never return null pointers - they either return a string with the relevant content, or an empty string if name/value is absent or if the handle is null. Also there are two notable things for reading values:</p>
+</div>
+<div class="ulist">
+<ul>
+<li>
+<p>It is common to store data as text contents of some node - i.e. <code>&lt;node&gt;&lt;description&gt;This is a node&lt;/description&gt;&lt;/node&gt;</code>. In this case, <code>&lt;description&gt;</code> node does not have a value, but instead has a child of type <code>node_pcdata</code> with value <code>"This is a node"</code>. pugixml provides <code>child_value()</code> and <code>text()</code> helper functions to parse such data.</p>
+</li>
+<li>
+<p>In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type.</p>
+</li>
+</ul>
+</div>
+<div class="paragraph">
+<p>This is an example of using these functions (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">);</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;: AllowRemote &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;AllowRemote&quot;</span><span class="tok-p">).</span><span class="tok-n">as_bool</span><span class="tok-p">();</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, Timeout &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Timeout&quot;</span><span class="tok-p">).</span><span class="tok-n">as_int</span><span class="tok-p">();</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, Description &#39;&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">child_value</span><span class="tok-p">(</span><span class="tok-s">&quot;Description&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;&#39;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose. For example, <code>child("Tool")</code> returns the first node which has the name <code>"Tool"</code>, or null handle if there is no such node. This is an example of using such functions (<a href="samples/traverse_base.cpp" class="bare">samples/traverse_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool for *.dae generation: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">find_child_by_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">,</span> <span class="tok-s">&quot;OutputFileMasks&quot;</span><span class="tok-p">,</span> <span class="tok-s">&quot;*.dae&quot;</span><span class="tok-p">).</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">);</span> <span class="tok-n">tool</span><span class="tok-p">;</span> <span class="tok-n">tool</span> <span class="tok-o">=</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">next_sibling</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Child node lists and attribute lists are simply double-linked lists; while you can use <code>previous_sibling</code>/<code>next_sibling</code> and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes. All iterators are bidirectional and support all usual iterator operations. The iterators are invalidated if the node/attribute objects they&#8217;re pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.</p>
+</div>
+<div class="paragraph">
+<p>Here is an example of using iterators for document traversal (<a href="samples/traverse_iter.cpp" class="bare">samples/traverse_iter.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node_iterator</span> <span class="tok-n">it</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">begin</span><span class="tok-p">();</span> <span class="tok-n">it</span> <span class="tok-o">!=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">end</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute_iterator</span> <span class="tok-n">ait</span> <span class="tok-o">=</span> <span class="tok-n">it</span><span class="tok-o">-&gt;</span><span class="tok-n">attributes_begin</span><span class="tok-p">();</span> <span class="tok-n">ait</span> <span class="tok-o">!=</span> <span class="tok-n">it</span><span class="tok-o">-&gt;</span><span class="tok-n">attributes_end</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">ait</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">ait</span><span class="tok-o">-&gt;</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">ait</span><span class="tok-o">-&gt;</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If your C&#43;&#43; compiler supports range-based for-loop (this is a C&#43;&#43;11 feature, at the time of writing it&#8217;s supported by Microsoft Visual Studio 11 Beta, GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with <a href="http://www.boost.org/libs/foreach/">Boost Foreach</a>, and possibly other pre-C&#43;&#43;11 foreach facilities.</p>
+</div>
+<div class="paragraph">
+<p>Here is an example of using C&#43;&#43;11 range-based for loop for document traversal (<a href="samples/traverse_rangefor.cpp" class="bare">samples/traverse_rangefor.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-nl">tool</span><span class="tok-p">:</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">(</span><span class="tok-s">&quot;Tool&quot;</span><span class="tok-p">))</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tool:&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-nl">attr</span><span class="tok-p">:</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">attributes</span><span class="tok-p">())</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-nl">child</span><span class="tok-p">:</span> <span class="tok-n">tool</span><span class="tok-p">.</span><span class="tok-n">children</span><span class="tok-p">())</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, child &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">child</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">();</span>
+ <span class="tok-p">}</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+<span class="tok-p">}</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you&#8217;ll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement <code>xml_tree_walker</code> interface and to call <code>traverse</code> function.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of traversing tree hierarchy with xml_tree_walker (<a href="samples/traverse_walker.cpp" class="bare">samples/traverse_walker.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">struct</span> <span class="tok-nl">simple_walker</span><span class="tok-p">:</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_tree_walker</span>
+<span class="tok-p">{</span>
+ <span class="tok-k">virtual</span> <span class="tok-kt">bool</span> <span class="tok-n">for_each</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span><span class="tok-o">&amp;</span> <span class="tok-n">node</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">i</span> <span class="tok-o">=</span> <span class="tok-mi">0</span><span class="tok-p">;</span> <span class="tok-n">i</span> <span class="tok-o">&lt;</span> <span class="tok-n">depth</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">i</span><span class="tok-p">)</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot; &quot;</span><span class="tok-p">;</span> <span class="tok-c1">// indentation</span>
+
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node_types</span><span class="tok-p">[</span><span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">type</span><span class="tok-p">()]</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;: name=&#39;&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;&#39;, value=&#39;&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;&#39;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+ <span class="tok-k">return</span> <span class="tok-nb">true</span><span class="tok-p">;</span> <span class="tok-c1">// continue traversal</span>
+ <span class="tok-p">}</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">simple_walker</span> <span class="tok-n">walker</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">traverse</span><span class="tok-p">(</span><span class="tok-n">walker</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Finally, for complex queries often a higher-level DSL is needed. pugixml provides an implementation of XPath 1.0 language for such queries. The complete description of XPath usage can be found in the manual, but here are some examples:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span> <span class="tok-n">tools</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_nodes</span><span class="tok-p">(</span><span class="tok-s">&quot;/Profile/Tools/Tool[@AllowRemote=&#39;true&#39; and @DeriveCaptionFrom=&#39;lastparam&#39;]&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Tools:</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+
+<span class="tok-k">for</span> <span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node_set</span><span class="tok-o">::</span><span class="tok-n">const_iterator</span> <span class="tok-n">it</span> <span class="tok-o">=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">begin</span><span class="tok-p">();</span> <span class="tok-n">it</span> <span class="tok-o">!=</span> <span class="tok-n">tools</span><span class="tok-p">.</span><span class="tok-n">end</span><span class="tok-p">();</span> <span class="tok-o">++</span><span class="tok-n">it</span><span class="tok-p">)</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-o">*</span><span class="tok-n">it</span><span class="tok-p">;</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-p">}</span>
+
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xpath_node</span> <span class="tok-n">build_tool</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">select_node</span><span class="tok-p">(</span><span class="tok-s">&quot;//Tool[contains(Description, &#39;build system&#39;)]&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-k">if</span> <span class="tok-p">(</span><span class="tok-n">build_tool</span><span class="tok-p">)</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Build tool: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">build_tool</span><span class="tok-p">.</span><span class="tok-n">node</span><span class="tok-p">().</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;Filename&quot;</span><span class="tok-p">).</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="admonitionblock caution">
+<table>
<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
-<th align="left">Caution</th>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+XPath functions throw <code>xpath_exception</code> objects on error; the sample above does not catch these exceptions.
+</td>
</tr>
-<tr><td align="left" valign="top"><p>
- XPath functions throw <code class="computeroutput"><span class="identifier">xpath_exception</span></code>
- objects on error; the sample above does not catch these exceptions.
- </p></td></tr>
-</table></div>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.modify"></a><a class="link" href="quickstart.html#quickstart.main.modify" title="Modifying document data"> Modifying document data</a>
-</h3></div></div></div>
-<p>
- The document in pugixml is fully mutable: you can completely change the document
- structure and modify the data of nodes/attributes. All functions take care
- of memory management and structural integrity themselves, so they always
- result in structurally valid tree - however, it is possible to create an
- invalid XML tree (for example, by adding two attributes with the same name
- or by setting attribute/node name to empty/invalid string). Tree modification
- is optimized for performance and for memory consumption, so if you have enough
- memory you can create documents from scratch with pugixml and later save
- them to file/stream instead of relying on error-prone manual text writing
- and without too much overhead.
- </p>
-<p>
- All member functions that change node/attribute data or structure are non-constant
- and thus can not be called on constant handles. However, you can easily convert
- constant handle to non-constant one by simple assignment: <code class="computeroutput"><span class="keyword">void</span>
- <span class="identifier">foo</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span><span class="special">&amp;</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">nc</span> <span class="special">=</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">}</span></code>, so const-correctness
- here mainly provides additional documentation.
- </p>
-<p>
- As discussed before, nodes can have name and value, both of which are strings.
- Depending on node type, name or value may be absent. You can use <code class="computeroutput"><span class="identifier">set_name</span></code> and <code class="computeroutput"><span class="identifier">set_value</span></code>
- member functions to set them. Similar functions are available for attributes;
- however, the <code class="computeroutput"><span class="identifier">set_value</span></code> function
- is overloaded for some other types except strings, like floating-point numbers.
- Also, attribute value can be set using an assignment operator. This is an
- example of setting node/attribute name and value (<a href="samples/modify_base.cpp" target="_top">samples/modify_base.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span>
-
-<span class="comment">// change node name
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"notnode"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", new node name: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// change comment text
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"useless comment"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", new comment text: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// we can't change value of the element or name of the comment
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"1"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">last_child</span><span class="special">().</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"2"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">attr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"id"</span><span class="special">);</span>
-
-<span class="comment">// change attribute name/value
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_name</span><span class="special">(</span><span class="string">"key"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"345"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">", new attribute: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">name</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="string">"="</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// we can use numbers or booleans
-</span><span class="identifier">attr</span><span class="special">.</span><span class="identifier">set_value</span><span class="special">(</span><span class="number">1.234</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"new attribute value: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-
-<span class="comment">// we can also use assignment operators for more concise code
-</span><span class="identifier">attr</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"final attribute value: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">attr</span><span class="special">.</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- Nodes and attributes do not exist without a document tree, so you can't create
- them without adding them to some document. A node or attribute can be created
- at the end of node/attribute list or before/after some other node. All insertion
- functions return the handle to newly created object on success, and null
- handle on failure. Even if the operation fails (for example, if you're trying
- to add a child node to PCDATA node), the document remains in consistent state,
- but the requested node/attribute is not added.
- </p>
-<div class="caution"><table border="0" summary="Caution">
+</table>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="modify"><a class="anchor" href="#modify"></a>Modifying document data</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.</p>
+</div>
+<div class="paragraph">
+<p>All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: <code>void foo(const pugi::xml_node&amp; n) { pugi::xml_node nc = n; }</code>, so const-correctness here mainly provides additional documentation.</p>
+</div>
+<div class="paragraph">
+<p>As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. You can use <code>set_name</code> and <code>set_value</code> member functions to set them. Similar functions are available for attributes; however, the <code>set_value</code> function is overloaded for some other types except strings, like floating-point numbers. Also, attribute value can be set using an assignment operator. This is an example of setting node/attribute name and value (<a href="samples/modify_base.cpp" class="bare">samples/modify_base.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// change node name</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">&quot;notnode&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, new node name: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// change comment text</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;useless comment&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, new comment text: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// we can&#39;t change value of the element or name of the comment</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;1&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">last_child</span><span class="tok-p">().</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">&quot;2&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-n">attr</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;id&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// change attribute name/value</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_name</span><span class="tok-p">(</span><span class="tok-s">&quot;key&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;345&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;, new attribute: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">name</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;=&quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// we can use numbers or booleans</span>
+<span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-mf">1.234</span><span class="tok-p">);</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;new attribute value: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span>
+
+<span class="tok-c1">// we can also use assignment operators for more concise code</span>
+<span class="tok-n">attr</span> <span class="tok-o">=</span> <span class="tok-nb">true</span><span class="tok-p">;</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;final attribute value: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">attr</span><span class="tok-p">.</span><span class="tok-n">value</span><span class="tok-p">()</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>Nodes and attributes do not exist without a document tree, so you can&#8217;t create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node. All insertion functions return the handle to newly created object on success, and null handle on failure. Even if the operation fails (for example, if you&#8217;re trying to add a child node to PCDATA node), the document remains in consistent state, but the requested node/attribute is not added.</p>
+</div>
+<div class="admonitionblock caution">
+<table>
<tr>
-<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
-<th align="left">Caution</th>
+<td class="icon">
+<div class="title">Caution</div>
+</td>
+<td class="content">
+<code>attribute()</code> and <code>child()</code> functions do not add attributes or nodes to the tree, so code like <code>node.attribute("id") = 123;</code> will not do anything if <code>node</code> does not have an attribute with name <code>"id"</code>. Make sure you&#8217;re operating with existing attributes/nodes by adding them if necessary.
+</td>
</tr>
-<tr><td align="left" valign="top"><p>
- attribute() and child() functions do not add attributes or nodes to the
- tree, so code like <code class="computeroutput"><span class="identifier">node</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"id"</span><span class="special">)</span> <span class="special">=</span> <span class="number">123</span><span class="special">;</span></code> will not do anything if <code class="computeroutput"><span class="identifier">node</span></code> does not have an attribute with
- name <code class="computeroutput"><span class="string">"id"</span></code>. Make sure
- you're operating with existing attributes/nodes by adding them if necessary.
- </p></td></tr>
-</table></div>
-<p>
- This is an example of adding new attributes/nodes to the document (<a href="samples/modify_add.cpp" target="_top">samples/modify_add.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// add node with some name
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span>
-
-<span class="comment">// add description node with text child
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">descr</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span>
-<span class="identifier">descr</span><span class="special">.</span><span class="identifier">append_child</span><span class="special">(</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">node_pcdata</span><span class="special">).</span><span class="identifier">set_value</span><span class="special">(</span><span class="string">"Simple node"</span><span class="special">);</span>
-
-<span class="comment">// add param node before the description
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">insert_child_before</span><span class="special">(</span><span class="string">"param"</span><span class="special">,</span> <span class="identifier">descr</span><span class="special">);</span>
-
-<span class="comment">// add attributes to param node
-</span><span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">)</span> <span class="special">=</span> <span class="string">"version"</span><span class="special">;</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">append_attribute</span><span class="special">(</span><span class="string">"value"</span><span class="special">)</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">;</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">insert_attribute_after</span><span class="special">(</span><span class="string">"type"</span><span class="special">,</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">))</span> <span class="special">=</span> <span class="string">"float"</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- If you do not want your document to contain some node or attribute, you can
- remove it with <code class="computeroutput"><span class="identifier">remove_attribute</span></code>
- and <code class="computeroutput"><span class="identifier">remove_child</span></code> functions.
- Removing the attribute or node invalidates all handles to the same underlying
- object, and also invalidates all iterators pointing to the same object. Removing
- node also invalidates all past-the-end iterators to its attribute or child
- node list. Be careful to ensure that all such handles and iterators either
- do not exist or are not used after the attribute/node is removed.
- </p>
-<p>
- This is an example of removing attributes/nodes from the document (<a href="samples/modify_remove.cpp" target="_top">samples/modify_remove.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// remove description node with the whole subtree
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">node</span> <span class="special">=</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"node"</span><span class="special">);</span>
-<span class="identifier">node</span><span class="special">.</span><span class="identifier">remove_child</span><span class="special">(</span><span class="string">"description"</span><span class="special">);</span>
-
-<span class="comment">// remove id attribute
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_node</span> <span class="identifier">param</span> <span class="special">=</span> <span class="identifier">node</span><span class="special">.</span><span class="identifier">child</span><span class="special">(</span><span class="string">"param"</span><span class="special">);</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="string">"value"</span><span class="special">);</span>
-
-<span class="comment">// we can also remove nodes/attributes by handles
-</span><span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_attribute</span> <span class="identifier">id</span> <span class="special">=</span> <span class="identifier">param</span><span class="special">.</span><span class="identifier">attribute</span><span class="special">(</span><span class="string">"name"</span><span class="special">);</span>
-<span class="identifier">param</span><span class="special">.</span><span class="identifier">remove_attribute</span><span class="special">(</span><span class="identifier">id</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.saving"></a><a class="link" href="quickstart.html#quickstart.main.saving" title="Saving document"> Saving document</a>
-</h3></div></div></div>
-<p>
- Often after creating a new document or loading the existing one and processing
- it, it is necessary to save the result back to file. Also it is occasionally
- useful to output the whole document or a subtree to some stream; use cases
- include debug printing, serialization via network or other text-oriented
- medium, etc. pugixml provides several functions to output any subtree of
- the document to a file, stream or another generic transport interface; these
- functions allow to customize the output format, and also perform necessary
- encoding conversions.
- </p>
-<p>
- Before writing to the destination the node/attribute data is properly formatted
- according to the node type; all special XML symbols, such as &lt; and &amp;,
- are properly escaped. In order to guard against forgotten node/attribute
- names, empty node/attribute names are printed as <code class="computeroutput"><span class="string">":anonymous"</span></code>.
- For well-formed output, make sure all node and attribute names are set to
- meaningful values.
- </p>
-<p>
- If you want to save the whole document to a file, you can use the <code class="computeroutput"><span class="identifier">save_file</span></code> function, which returns <code class="computeroutput"><span class="keyword">true</span></code> on success. This is a simple example
- of saving XML document to file (<a href="samples/save_file.cpp" target="_top">samples/save_file.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// save document to file
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Saving result: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">doc</span><span class="special">.</span><span class="identifier">save_file</span><span class="special">(</span><span class="string">"save_file_output.xml"</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- To enhance interoperability pugixml provides functions for saving document
- to any object which implements C++ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span></code>
- interface. This allows you to save documents to any standard C++ stream (i.e.
- file stream) or any third-party compliant implementation (i.e. Boost Iostreams).
- Most notably, this allows for easy debug output, since you can use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span></code>
- stream as saving target. There are two functions, one works with narrow character
- streams, another handles wide character ones.
- </p>
-<p>
- This is a simple example of saving XML document to standard output (<a href="samples/save_stream.cpp" target="_top">samples/save_stream.cpp</a>):
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="comment">// save document to standard output
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Document:\n"</span><span class="special">;</span>
-<span class="identifier">doc</span><span class="special">.</span><span class="identifier">save</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
- All of the above saving functions are implemented in terms of writer interface.
- This is a simple interface with a single function, which is called several
- times during output process with chunks of document data as input. In order
- to output the document via some custom transport, for example sockets, you
- should create an object which implements <code class="computeroutput"><span class="identifier">xml_writer_file</span></code>
- interface and pass it to <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span></code>
- function.
- </p>
-<p>
- This is a simple example of custom writer for saving document data to STL
- string (<a href="samples/save_custom_writer.cpp" target="_top">samples/save_custom_writer.cpp</a>);
- read the sample code for more complex examples:
- </p>
-<p>
-
-</p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xml_string_writer</span><span class="special">:</span> <span class="identifier">pugi</span><span class="special">::</span><span class="identifier">xml_writer</span>
-<span class="special">{</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">result</span><span class="special">;</span>
-
- <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="identifier">write</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">data</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">size</span><span class="special">)</span>
- <span class="special">{</span>
- <span class="identifier">result</span> <span class="special">+=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*&gt;(</span><span class="identifier">data</span><span class="special">),</span> <span class="identifier">size</span><span class="special">);</span>
- <span class="special">}</span>
-<span class="special">};</span>
-</pre>
-<p>
- </p>
-<p>
- While the previously described functions save the whole document to the destination,
- it is easy to save a single subtree. Instead of calling <code class="computeroutput"><span class="identifier">xml_document</span><span class="special">::</span><span class="identifier">save</span></code>,
- just call <code class="computeroutput"><span class="identifier">xml_node</span><span class="special">::</span><span class="identifier">print</span></code> function on the target node. You
- can save node contents to C++ IOstream object or custom writer in this way.
- Saving a subtree slightly differs from saving the whole document; <a href="manual/saving.html#manual.saving.subtree" target="_top">read the manual</a> for
- more information.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.feedback"></a><a class="link" href="quickstart.html#quickstart.main.feedback" title="Feedback"> Feedback</a>
-</h3></div></div></div>
-<p>
- If you believe you've found a bug in pugixml, please file an issue via <a href="http://code.google.com/p/pugixml/issues/entry" target="_top">issue submission form</a>.
- Be sure to include the relevant information so that the bug can be reproduced:
- the version of pugixml, compiler version and target architecture, the code
- that uses pugixml and exhibits the bug, etc. Feature requests and contributions
- can be filed as issues, too.
- </p>
-<a name="email"></a><p>
- If filing an issue is not possible due to privacy or other concerns, you
- can contact pugixml author by e-mail directly: <a href="mailto:arseny.kapoulkine@gmail.com" target="_top">arseny.kapoulkine@gmail.com</a>.
- </p>
-</div>
-<div class="section">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="quickstart.main.license"></a><a class="link" href="quickstart.html#quickstart.main.license" title="License"> License</a>
-</h3></div></div></div>
-<p>
- The pugixml library is distributed under the MIT license:
- </p>
-<div class="blockquote"><blockquote class="blockquote">
-<p>
- Copyright (c) 2006-2014 Arseny Kapoulkine
- </p>
-<p>
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the "Software"),
- to deal in the Software without restriction, including without limitation
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
- and/or sell copies of the Software, and to permit persons to whom the Software
- is furnished to do so, subject to the following conditions:
- </p>
-<p>
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
- </p>
-<p>
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- IN THE SOFTWARE.
- </p>
-</blockquote></div>
-<p>
- This means that you can freely use pugixml in your applications, both open-source
- and proprietary. If you use pugixml in a product, it is sufficient to add
- an acknowledgment like this to the product distribution:
- </p>
-<div class="blockquote"><blockquote class="blockquote"><p>
- This software is based on pugixml library (http://pugixml.org).<br>
-pugixml
- is Copyright (C) 2006-2014 Arseny Kapoulkine.
- </p></blockquote></div>
-</div>
-</div>
-<div class="footnotes">
-<br><hr style="width:100; text-align:left;margin-left: 0">
-<div id="ftn.trademarks" class="footnote"><p><a href="#trademarks" class="para"><sup class="para">[1] </sup></a>All trademarks used are properties of their respective owners.</p></div>
-</div>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: November 18, 2014 at 17:25:31 GMT</small></p></td>
-<td align="right"><div class="copyright-footer"></div></td>
-</tr></table>
+</table>
+</div>
+<div class="paragraph">
+<p>This is an example of adding new attributes/nodes to the document (<a href="samples/modify_add.cpp" class="bare">samples/modify_add.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// add node with some name</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add description node with text child</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">descr</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-s">&quot;description&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">descr</span><span class="tok-p">.</span><span class="tok-n">append_child</span><span class="tok-p">(</span><span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">node_pcdata</span><span class="tok-p">).</span><span class="tok-n">set_value</span><span class="tok-p">(</span><span class="tok-s">&quot;Simple node&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add param node before the description</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">param</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">insert_child_before</span><span class="tok-p">(</span><span class="tok-s">&quot;param&quot;</span><span class="tok-p">,</span> <span class="tok-n">descr</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// add attributes to param node</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-s">&quot;version&quot;</span><span class="tok-p">;</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">append_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;value&quot;</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-mf">1.1</span><span class="tok-p">;</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">insert_attribute_after</span><span class="tok-p">(</span><span class="tok-s">&quot;type&quot;</span><span class="tok-p">,</span> <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">))</span> <span class="tok-o">=</span> <span class="tok-s">&quot;float&quot;</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>If you do not want your document to contain some node or attribute, you can remove it with <code>remove_attribute</code> and <code>remove_child</code> functions. Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed.</p>
+</div>
+<div class="paragraph">
+<p>This is an example of removing attributes/nodes from the document (<a href="samples/modify_remove.cpp" class="bare">samples/modify_remove.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// remove description node with the whole subtree</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">node</span> <span class="tok-o">=</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;node&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">remove_child</span><span class="tok-p">(</span><span class="tok-s">&quot;description&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// remove id attribute</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_node</span> <span class="tok-n">param</span> <span class="tok-o">=</span> <span class="tok-n">node</span><span class="tok-p">.</span><span class="tok-n">child</span><span class="tok-p">(</span><span class="tok-s">&quot;param&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;value&quot;</span><span class="tok-p">);</span>
+
+<span class="tok-c1">// we can also remove nodes/attributes by handles</span>
+<span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_attribute</span> <span class="tok-n">id</span> <span class="tok-o">=</span> <span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">attribute</span><span class="tok-p">(</span><span class="tok-s">&quot;name&quot;</span><span class="tok-p">);</span>
+<span class="tok-n">param</span><span class="tok-p">.</span><span class="tok-n">remove_attribute</span><span class="tok-p">(</span><span class="tok-n">id</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="saving"><a class="anchor" href="#saving"></a>Saving document</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format, and also perform necessary encoding conversions.</p>
+</div>
+<div class="paragraph">
+<p>Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as &lt; and &amp;, are properly escaped. In order to guard against forgotten node/attribute names, empty node/attribute names are printed as <code>":anonymous"</code>. For well-formed output, make sure all node and attribute names are set to meaningful values.</p>
+</div>
+<div class="paragraph">
+<p>If you want to save the whole document to a file, you can use the <code>save_file</code> function, which returns <code>true</code> on success. This is a simple example of saving XML document to file (<a href="samples/save_file.cpp" class="bare">samples/save_file.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// save document to file</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Saving result: &quot;</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save_file</span><span class="tok-p">(</span><span class="tok-s">&quot;save_file_output.xml&quot;</span><span class="tok-p">)</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">endl</span><span class="tok-p">;</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>To enhance interoperability pugixml provides functions for saving document to any object which implements C&#43;&#43; <code>std::ostream</code> interface. This allows you to save documents to any standard C&#43;&#43; stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use <code>std::cout</code> stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of saving XML document to standard output (<a href="samples/save_stream.cpp" class="bare">samples/save_stream.cpp</a>):</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-c1">// save document to standard output</span>
+<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o">&lt;&lt;</span> <span class="tok-s">&quot;Document:</span><span class="tok-se">\n</span><span class="tok-s">&quot;</span><span class="tok-p">;</span>
+<span class="tok-n">doc</span><span class="tok-p">.</span><span class="tok-n">save</span><span class="tok-p">(</span><span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span><span class="tok-p">);</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input. In order to output the document via some custom transport, for example sockets, you should create an object which implements <code>xml_writer_file</code> interface and pass it to <code>xml_document::save</code> function.</p>
+</div>
+<div class="paragraph">
+<p>This is a simple example of custom writer for saving document data to STL string (<a href="samples/save_custom_writer.cpp" class="bare">samples/save_custom_writer.cpp</a>); read the sample code for more complex examples:</p>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="pygments highlight"><code data-lang="c++"><span class="tok-k">struct</span> <span class="tok-nl">xml_string_writer</span><span class="tok-p">:</span> <span class="tok-n">pugi</span><span class="tok-o">::</span><span class="tok-n">xml_writer</span>
+<span class="tok-p">{</span>
+ <span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">string</span> <span class="tok-n">result</span><span class="tok-p">;</span>
+
+ <span class="tok-k">virtual</span> <span class="tok-kt">void</span> <span class="tok-nf">write</span><span class="tok-p">(</span><span class="tok-k">const</span> <span class="tok-kt">void</span><span class="tok-o">*</span> <span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-kt">size_t</span> <span class="tok-n">size</span><span class="tok-p">)</span>
+ <span class="tok-p">{</span>
+ <span class="tok-n">result</span><span class="tok-p">.</span><span class="tok-n">append</span><span class="tok-p">(</span><span class="tok-k">static_cast</span><span class="tok-o">&lt;</span><span class="tok-k">const</span> <span class="tok-kt">char</span><span class="tok-o">*&gt;</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">),</span> <span class="tok-n">size</span><span class="tok-p">);</span>
+ <span class="tok-p">}</span>
+<span class="tok-p">};</span></code></pre>
+</div>
+</div>
+<div class="paragraph">
+<p>While the previously described functions save the whole document to the destination, it is easy to save a single subtree. Instead of calling <code>xml_document::save</code>, just call <code>xml_node::print</code> function on the target node. You can save node contents to C&#43;&#43; IOstream object or custom writer in this way. Saving a subtree slightly differs from saving the whole document; <a href="manual/saving.html#saving.subtree">read the manual</a> for more information.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="feedback"><a class="anchor" href="#feedback"></a>Feedback</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>If you believe you&#8217;ve found a bug in pugixml, please file an issue via <a href="https://github.com/zeux/pugixml/issues/new">issue submission form</a>. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc. Feature requests and contributions can be filed as issues, too.</p>
+</div>
+<div class="paragraph">
+<p>If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: <a href="mailto:arseny.kapoulkine@gmail.com">arseny.kapoulkine@gmail.com</a>.</p>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="license"><a class="anchor" href="#license"></a>License</h2>
+<div class="sectionbody">
+<div class="paragraph">
+<p>The pugixml library is distributed under the MIT license:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>Copyright (c) 2006-2015 Arseny Kapoulkine
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.</pre>
+</div>
+</div>
+<div class="paragraph">
+<p>This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:</p>
+</div>
+<div class="literalblock">
+<div class="content">
+<pre>This software is based on pugixml library (http://pugixml.org).
+pugixml is Copyright (C) 2006-2015 Arseny Kapoulkine.</pre>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="footnotes">
+<hr>
+<div class="footnote" id="_footnote_1">
+<a href="#_footnoteref_1">1</a>. All trademarks used are properties of their respective owners.
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2015-03-24 20:19:09 PDT
+</div>
+</div>
</body>
-</html>
+</html> \ No newline at end of file
diff --git a/docs/quickstart.xsl b/docs/quickstart.xsl
deleted file mode 100644
index 0ad5704..0000000
--- a/docs/quickstart.xsl
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version='1.0'?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
- <xsl:param name="generate.toc">section toc</xsl:param>
-
- <xsl:template name="header.navigation" />
- <xsl:template name="footer.navigation" />
- <xsl:template name="article.titlepage" />
-</xsl:stylesheet>
diff --git a/docs/samples/custom_memory_management.cpp b/docs/samples/custom_memory_management.cpp
index f11d27e..2cb5520 100644
--- a/docs/samples/custom_memory_management.cpp
+++ b/docs/samples/custom_memory_management.cpp
@@ -2,7 +2,7 @@
#include <new>
-//[code_custom_memory_management_decl
+// tag::decl[]
void* custom_allocate(size_t size)
{
return new (std::nothrow) char[size];
@@ -12,13 +12,13 @@ void custom_deallocate(void* ptr)
{
delete[] static_cast<char*>(ptr);
}
-//]
+// end::decl[]
int main()
{
-//[code_custom_memory_management_call
+// tag::call[]
pugi::set_memory_management_functions(custom_allocate, custom_deallocate);
-//]
+// end::call[]
pugi::xml_document doc;
doc.load_string("<node/>");
diff --git a/docs/samples/include.cpp b/docs/samples/include.cpp
index fa615a4..39830c5 100644
--- a/docs/samples/include.cpp
+++ b/docs/samples/include.cpp
@@ -3,7 +3,7 @@
#include <string.h>
#include <iostream>
-//[code_include
+// tag::code[]
bool load_preprocess(pugi::xml_document& doc, const char* path);
bool preprocess(pugi::xml_node node)
@@ -51,7 +51,7 @@ bool load_preprocess(pugi::xml_document& doc, const char* path)
return result ? preprocess(doc) : false;
}
-//]
+// end::code[]
int main()
{
diff --git a/docs/samples/load_error_handling.cpp b/docs/samples/load_error_handling.cpp
index 8dceb99..d1e5a49 100644
--- a/docs/samples/load_error_handling.cpp
+++ b/docs/samples/load_error_handling.cpp
@@ -4,19 +4,21 @@
void check_xml(const char* source)
{
-//[code_load_error_handling
+// tag::code[]
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_string(source);
if (result)
+ {
std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n\n";
+ }
else
{
std::cout << "XML [" << source << "] parsed with errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n";
std::cout << "Error description: " << result.description() << "\n";
std::cout << "Error offset: " << result.offset << " (error at [..." << (source + result.offset) << "]\n\n";
}
-//]
+// end::code[]
}
int main()
diff --git a/docs/samples/load_file.cpp b/docs/samples/load_file.cpp
index f7b06c9..8b2191b 100644
--- a/docs/samples/load_file.cpp
+++ b/docs/samples/load_file.cpp
@@ -4,13 +4,13 @@
int main()
{
-//[code_load_file
+// tag::code[]
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file("tree.xml");
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
-//]
+// end::code[]
}
// vim:et
diff --git a/docs/samples/load_memory.cpp b/docs/samples/load_memory.cpp
index 490f7e4..80bba3c 100644
--- a/docs/samples/load_memory.cpp
+++ b/docs/samples/load_memory.cpp
@@ -5,41 +5,42 @@
int main()
{
-//[code_load_memory_decl
+// tag::decl[]
const char source[] = "<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>";
size_t size = sizeof(source);
-//]
+// end::decl[]
pugi::xml_document doc;
{
- //[code_load_memory_buffer
+ // tag::load_buffer[]
// You can use load_buffer to load document from immutable memory block:
pugi::xml_parse_result result = doc.load_buffer(source, size);
- //]
+ // end::load_buffer[]
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
}
{
- //[code_load_memory_buffer_inplace
+ // tag::load_buffer_inplace_begin[]
// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document
char* buffer = new char[size];
memcpy(buffer, source, size);
// The block can be allocated by any method; the block is modified during parsing
pugi::xml_parse_result result = doc.load_buffer_inplace(buffer, size);
+ // end::load_buffer_inplace_begin[]
- //<-
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
- //->
+
+ // tag::load_buffer_inplace_end[]
// You have to destroy the block yourself after the document is no longer used
delete[] buffer;
- //]
+ // end::load_buffer_inplace_end[]
}
{
- //[code_load_memory_buffer_inplace_own
+ // tag::load_buffer_inplace_own[]
// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block
// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect
char* buffer = static_cast<char*>(pugi::get_memory_allocation_function()(size));
@@ -47,16 +48,16 @@ int main()
// The block will be deleted by the document
pugi::xml_parse_result result = doc.load_buffer_inplace_own(buffer, size);
- //]
+ // end::load_buffer_inplace_own[]
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
}
{
- //[code_load_memory_string
+ // tag::load_string[]
// You can use load to load document from null-terminated strings, for example literals:
pugi::xml_parse_result result = doc.load_string("<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>");
- //]
+ // end::load_string[]
std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
}
diff --git a/docs/samples/load_options.cpp b/docs/samples/load_options.cpp
index 2589348..b7b0a6b 100644
--- a/docs/samples/load_options.cpp
+++ b/docs/samples/load_options.cpp
@@ -6,7 +6,7 @@ int main()
{
pugi::xml_document doc;
-//[code_load_options
+// tag::code[]
const char* source = "<!--comment--><node>&lt;</node>";
// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded
@@ -24,7 +24,7 @@ int main()
// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded
doc.load_string(source, pugi::parse_minimal);
std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
-//]
+// end::code[]
}
// vim:et
diff --git a/docs/samples/load_stream.cpp b/docs/samples/load_stream.cpp
index 05cfb7f..f982a83 100644
--- a/docs/samples/load_stream.cpp
+++ b/docs/samples/load_stream.cpp
@@ -33,10 +33,10 @@ int main()
pugi::xml_document doc;
{
- //[code_load_stream
+ // tag::code[]
std::ifstream stream("weekly-utf-8.xml");
pugi::xml_parse_result result = doc.load(stream);
- //]
+ // end::code[]
// first character of root name: U+9031, year: 1997
print_doc("UTF8 file from narrow stream", doc, result);
diff --git a/docs/samples/modify_add.cpp b/docs/samples/modify_add.cpp
index 04ab445..a2ddd31 100644
--- a/docs/samples/modify_add.cpp
+++ b/docs/samples/modify_add.cpp
@@ -6,7 +6,7 @@ int main()
{
pugi::xml_document doc;
- //[code_modify_add
+ // tag::code[]
// add node with some name
pugi::xml_node node = doc.append_child("node");
@@ -21,7 +21,7 @@ int main()
param.append_attribute("name") = "version";
param.append_attribute("value") = 1.1;
param.insert_attribute_after("type", param.attribute("name")) = "float";
- //]
+ // end::code[]
doc.print(std::cout);
}
diff --git a/docs/samples/modify_base.cpp b/docs/samples/modify_base.cpp
index bd63708..7c4819b 100644
--- a/docs/samples/modify_base.cpp
+++ b/docs/samples/modify_base.cpp
@@ -8,7 +8,7 @@ int main()
pugi::xml_document doc;
if (!doc.load_string("<node id='123'>text</node><!-- comment -->", pugi::parse_default | pugi::parse_comments)) return -1;
- //[code_modify_base_node
+ // tag::node[]
pugi::xml_node node = doc.child("node");
// change node name
@@ -21,9 +21,9 @@ int main()
// we can't change value of the element or name of the comment
std::cout << node.set_value("1") << ", " << doc.last_child().set_name("2") << std::endl;
- //]
+ // end::node[]
- //[code_modify_base_attr
+ // tag::attr[]
pugi::xml_attribute attr = node.attribute("id");
// change attribute name/value
@@ -37,7 +37,7 @@ int main()
// we can also use assignment operators for more concise code
attr = true;
std::cout << "final attribute value: " << attr.value() << std::endl;
- //]
+ // end::attr[]
}
// vim:et
diff --git a/docs/samples/modify_remove.cpp b/docs/samples/modify_remove.cpp
index 53020e1..d54c0d8 100644
--- a/docs/samples/modify_remove.cpp
+++ b/docs/samples/modify_remove.cpp
@@ -7,7 +7,7 @@ int main()
pugi::xml_document doc;
if (!doc.load_string("<node><description>Simple node</description><param name='id' value='123'/></node>")) return -1;
- //[code_modify_remove
+ // tag::code[]
// remove description node with the whole subtree
pugi::xml_node node = doc.child("node");
node.remove_child("description");
@@ -19,7 +19,7 @@ int main()
// we can also remove nodes/attributes by handles
pugi::xml_attribute id = param.attribute("name");
param.remove_attribute(id);
- //]
+ // end::code[]
doc.print(std::cout);
}
diff --git a/docs/samples/save_custom_writer.cpp b/docs/samples/save_custom_writer.cpp
index fe08b72..e777a32 100644
--- a/docs/samples/save_custom_writer.cpp
+++ b/docs/samples/save_custom_writer.cpp
@@ -4,7 +4,7 @@
#include <iostream>
#include <cstring>
-//[code_save_custom_writer
+// tag::code[]
struct xml_string_writer: pugi::xml_writer
{
std::string result;
@@ -14,7 +14,7 @@ struct xml_string_writer: pugi::xml_writer
result.append(static_cast<const char*>(data), size);
}
};
-//]
+// end::code[]
struct xml_memory_writer: pugi::xml_writer
{
diff --git a/docs/samples/save_declaration.cpp b/docs/samples/save_declaration.cpp
index a45831f..7ca1e07 100644
--- a/docs/samples/save_declaration.cpp
+++ b/docs/samples/save_declaration.cpp
@@ -1,27 +1,27 @@
-#include "pugixml.hpp"
-
-#include <iostream>
-
-int main()
-{
- //[code_save_declaration
- // get a test document
- pugi::xml_document doc;
- doc.load_string("<foo bar='baz'><call>hey</call></foo>");
-
- // add a custom declaration node
- pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
- decl.append_attribute("version") = "1.0";
- decl.append_attribute("encoding") = "UTF-8";
- decl.append_attribute("standalone") = "no";
-
- // <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- // <foo bar="baz">
- // <call>hey</call>
- // </foo>
- doc.save(std::cout);
- std::cout << std::endl;
- //]
-}
-
-// vim:et
+#include "pugixml.hpp"
+
+#include <iostream>
+
+int main()
+{
+ // tag::code[]
+ // get a test document
+ pugi::xml_document doc;
+ doc.load_string("<foo bar='baz'><call>hey</call></foo>");
+
+ // add a custom declaration node
+ pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
+ decl.append_attribute("version") = "1.0";
+ decl.append_attribute("encoding") = "UTF-8";
+ decl.append_attribute("standalone") = "no";
+
+ // <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ // <foo bar="baz">
+ // <call>hey</call>
+ // </foo>
+ doc.save(std::cout);
+ std::cout << std::endl;
+ // end::code[]
+}
+
+// vim:et
diff --git a/docs/samples/save_file.cpp b/docs/samples/save_file.cpp
index 21413a2..10c6104 100644
--- a/docs/samples/save_file.cpp
+++ b/docs/samples/save_file.cpp
@@ -8,10 +8,10 @@ int main()
pugi::xml_document doc;
doc.load_string("<foo bar='baz'>hey</foo>");
- //[code_save_file
+ // tag::code[]
// save document to file
std::cout << "Saving result: " << doc.save_file("save_file_output.xml") << std::endl;
- //]
+ // end::code[]
}
// vim:et
diff --git a/docs/samples/save_options.cpp b/docs/samples/save_options.cpp
index 82abdcd..e196946 100644
--- a/docs/samples/save_options.cpp
+++ b/docs/samples/save_options.cpp
@@ -4,7 +4,7 @@
int main()
{
- //[code_save_options
+ // tag::code[]
// get a test document
pugi::xml_document doc;
doc.load_string("<foo bar='baz'><call>hey</call></foo>");
@@ -42,7 +42,7 @@ int main()
// <foo bar="baz"><call>hey</call></foo>
doc.save(std::cout, "\t", pugi::format_raw | pugi::format_no_declaration);
std::cout << std::endl;
- //]
+ // end::code[]
}
// vim:et
diff --git a/docs/samples/save_stream.cpp b/docs/samples/save_stream.cpp
index eba1863..84a33bf 100644
--- a/docs/samples/save_stream.cpp
+++ b/docs/samples/save_stream.cpp
@@ -8,11 +8,11 @@ int main()
pugi::xml_document doc;
doc.load_string("<foo bar='baz'><call>hey</call></foo>");
- //[code_save_stream
+ // tag::code[]
// save document to standard output
std::cout << "Document:\n";
doc.save(std::cout);
- //]
+ // end::code[]
}
// vim:et
diff --git a/docs/samples/save_subtree.cpp b/docs/samples/save_subtree.cpp
index a94e10a..5ae4830 100644
--- a/docs/samples/save_subtree.cpp
+++ b/docs/samples/save_subtree.cpp
@@ -4,7 +4,7 @@
int main()
{
- //[code_save_subtree
+ // tag::code[]
// get a test document
pugi::xml_document doc;
doc.load_string("<foo bar='baz'><call>hey</call></foo>");
@@ -20,7 +20,7 @@ int main()
// print a subtree to standard output (prints <call>hey</call>)
doc.child("foo").child("call").print(std::cout, "", pugi::format_raw);
std::cout << std::endl;
- //]
+ // end::code[]
}
// vim:et
diff --git a/docs/samples/text.cpp b/docs/samples/text.cpp
index a0d591b..0b4bae6 100644
--- a/docs/samples/text.cpp
+++ b/docs/samples/text.cpp
@@ -1,35 +1,35 @@
-#include "pugixml.hpp"
-
-#include <iostream>
-
-int main()
-{
- pugi::xml_document doc;
-
- // get a test document
- doc.load_string("<project><name>test</name><version>1.1</version><public>yes</public></project>");
-
- pugi::xml_node project = doc.child("project");
-
- //[code_text_access
- std::cout << "Project name: " << project.child("name").text().get() << std::endl;
- std::cout << "Project version: " << project.child("version").text().as_double() << std::endl;
- std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl;
- std::cout << "Project description: " << project.child("description").text().get() << std::endl;
- //]
-
- std::cout << std::endl;
-
- //[code_text_modify
- // change project version
- project.child("version").text() = 1.2;
-
- // add description element and set the contents
- // note that we do not have to explicitly add the node_pcdata child
- project.append_child("description").text().set("a test project");
- //]
-
- doc.save(std::cout);
-}
-
-// vim:et
+#include "pugixml.hpp"
+
+#include <iostream>
+
+int main()
+{
+ pugi::xml_document doc;
+
+ // get a test document
+ doc.load_string("<project><name>test</name><version>1.1</version><public>yes</public></project>");
+
+ pugi::xml_node project = doc.child("project");
+
+ // tag::access[]
+ std::cout << "Project name: " << project.child("name").text().get() << std::endl;
+ std::cout << "Project version: " << project.child("version").text().as_double() << std::endl;
+ std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl;
+ std::cout << "Project description: " << project.child("description").text().get() << std::endl;
+ // end::access[]
+
+ std::cout << std::endl;
+
+ // tag::modify[]
+ // change project version
+ project.child("version").text() = 1.2;
+
+ // add description element and set the contents
+ // note that we do not have to explicitly add the node_pcdata child
+ project.append_child("description").text().set("a test project");
+ // end::modify[]
+
+ doc.save(std::cout);
+}
+
+// vim:et
diff --git a/docs/samples/traverse_base.cpp b/docs/samples/traverse_base.cpp
index d59c8b0..3ee7fe4 100644
--- a/docs/samples/traverse_base.cpp
+++ b/docs/samples/traverse_base.cpp
@@ -10,7 +10,7 @@ int main()
pugi::xml_node tools = doc.child("Profile").child("Tools");
- //[code_traverse_base_basic
+ // tag::basic[]
for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling())
{
std::cout << "Tool:";
@@ -22,11 +22,11 @@ int main()
std::cout << std::endl;
}
- //]
+ // end::basic[]
std::cout << std::endl;
- //[code_traverse_base_data
+ // tag::data[]
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
{
std::cout << "Tool " << tool.attribute("Filename").value();
@@ -34,18 +34,18 @@ int main()
std::cout << ", Timeout " << tool.attribute("Timeout").as_int();
std::cout << ", Description '" << tool.child_value("Description") << "'\n";
}
- //]
+ // end::data[]
std::cout << std::endl;
- //[code_traverse_base_contents
+ // tag::contents[]
std::cout << "Tool for *.dae generation: " << tools.find_child_by_attribute("Tool", "OutputFileMasks", "*.dae").attribute("Filename").value() << "\n";
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
{
std::cout << "Tool " << tool.attribute("Filename").value() << "\n";
}
- //]
+ // end::contents[]
}
// vim:et
diff --git a/docs/samples/traverse_iter.cpp b/docs/samples/traverse_iter.cpp
index 90e0dc6..77bcf35 100644
--- a/docs/samples/traverse_iter.cpp
+++ b/docs/samples/traverse_iter.cpp
@@ -9,7 +9,7 @@ int main()
pugi::xml_node tools = doc.child("Profile").child("Tools");
- //[code_traverse_iter
+ // tag::code[]
for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it)
{
std::cout << "Tool:";
@@ -21,7 +21,7 @@ int main()
std::cout << std::endl;
}
- //]
+ // end::code[]
}
// vim:et
diff --git a/docs/samples/traverse_predicate.cpp b/docs/samples/traverse_predicate.cpp
index 9d8ded0..40e1718 100644
--- a/docs/samples/traverse_predicate.cpp
+++ b/docs/samples/traverse_predicate.cpp
@@ -3,7 +3,7 @@
#include <string.h>
#include <iostream>
-//[code_traverse_predicate_decl
+// tag::decl[]
bool small_timeout(pugi::xml_node node)
{
return node.attribute("Timeout").as_int() < 20;
@@ -21,7 +21,7 @@ struct allow_remote_predicate
return node.attribute("AllowRemote").as_bool();
}
};
-//]
+// end::decl[]
int main()
{
@@ -30,7 +30,7 @@ int main()
pugi::xml_node tools = doc.child("Profile").child("Tools");
- //[code_traverse_predicate_find
+ // tag::find[]
// Find child via predicate (looks for direct children only)
std::cout << tools.find_child(allow_remote_predicate()).attribute("Filename").value() << std::endl;
@@ -42,7 +42,7 @@ int main()
// We can use simple functions instead of function objects
std::cout << tools.find_child(small_timeout).attribute("Filename").value() << std::endl;
- //]
+ // end::find[]
}
// vim:et
diff --git a/docs/samples/traverse_rangefor.cpp b/docs/samples/traverse_rangefor.cpp
index 1f7212e..8d9d7d5 100644
--- a/docs/samples/traverse_rangefor.cpp
+++ b/docs/samples/traverse_rangefor.cpp
@@ -1,32 +1,32 @@
-#include "pugixml.hpp"
-
-#include <iostream>
-
-int main()
-{
- pugi::xml_document doc;
- if (!doc.load_file("xgconsole.xml")) return -1;
-
- pugi::xml_node tools = doc.child("Profile").child("Tools");
-
- //[code_traverse_rangefor
- for (pugi::xml_node tool: tools.children("Tool"))
- {
- std::cout << "Tool:";
-
- for (pugi::xml_attribute attr: tool.attributes())
- {
- std::cout << " " << attr.name() << "=" << attr.value();
- }
-
- for (pugi::xml_node child: tool.children())
- {
- std::cout << ", child " << child.name();
- }
-
- std::cout << std::endl;
- }
- //]
-}
-
-// vim:et
+#include "pugixml.hpp"
+
+#include <iostream>
+
+int main()
+{
+ pugi::xml_document doc;
+ if (!doc.load_file("xgconsole.xml")) return -1;
+
+ pugi::xml_node tools = doc.child("Profile").child("Tools");
+
+ // tag::code[]
+ for (pugi::xml_node tool: tools.children("Tool"))
+ {
+ std::cout << "Tool:";
+
+ for (pugi::xml_attribute attr: tool.attributes())
+ {
+ std::cout << " " << attr.name() << "=" << attr.value();
+ }
+
+ for (pugi::xml_node child: tool.children())
+ {
+ std::cout << ", child " << child.name();
+ }
+
+ std::cout << std::endl;
+ }
+ // end::code[]
+}
+
+// vim:et
diff --git a/docs/samples/traverse_walker.cpp b/docs/samples/traverse_walker.cpp
index cb99902..2f4b11b 100644
--- a/docs/samples/traverse_walker.cpp
+++ b/docs/samples/traverse_walker.cpp
@@ -7,7 +7,7 @@ const char* node_types[] =
"null", "document", "element", "pcdata", "cdata", "comment", "pi", "declaration"
};
-//[code_traverse_walker_impl
+// tag::impl[]
struct simple_walker: pugi::xml_tree_walker
{
virtual bool for_each(pugi::xml_node& node)
@@ -19,17 +19,17 @@ struct simple_walker: pugi::xml_tree_walker
return true; // continue traversal
}
};
-//]
+// end::impl[]
int main()
{
pugi::xml_document doc;
if (!doc.load_file("tree.xml")) return -1;
- //[code_traverse_walker_traverse
+ // tag::traverse[]
simple_walker walker;
doc.traverse(walker);
- //]
+ // end::traverse[]
}
// vim:et
diff --git a/docs/samples/xpath_error.cpp b/docs/samples/xpath_error.cpp
index 6cb6f4f..b6dc424 100644
--- a/docs/samples/xpath_error.cpp
+++ b/docs/samples/xpath_error.cpp
@@ -7,7 +7,7 @@ int main()
pugi::xml_document doc;
if (!doc.load_file("xgconsole.xml")) return -1;
-//[code_xpath_error
+// tag::code[]
// Exception is thrown for incorrect query syntax
try
{
@@ -37,7 +37,7 @@ int main()
{
std::cout << "Select failed: " << e.what() << std::endl;
}
-//]
+// end::code[]
}
// vim:et
diff --git a/docs/samples/xpath_query.cpp b/docs/samples/xpath_query.cpp
index c622a9c..857c04c 100644
--- a/docs/samples/xpath_query.cpp
+++ b/docs/samples/xpath_query.cpp
@@ -8,7 +8,7 @@ int main()
pugi::xml_document doc;
if (!doc.load_file("xgconsole.xml")) return -1;
-//[code_xpath_query
+// tag::code[]
// Select nodes via compiled query
pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote='true']");
@@ -30,7 +30,7 @@ int main()
if (query_name_valid.evaluate_boolean(tool)) std::cout << s << std::endl;
}
-//]
+// end::code[]
}
// vim:et
diff --git a/docs/samples/xpath_select.cpp b/docs/samples/xpath_select.cpp
index 74dad60..f6067a3 100644
--- a/docs/samples/xpath_select.cpp
+++ b/docs/samples/xpath_select.cpp
@@ -7,7 +7,7 @@ int main()
pugi::xml_document doc;
if (!doc.load_file("xgconsole.xml")) return -1;
-//[code_xpath_select
+// tag::code[]
pugi::xpath_node_set tools = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']");
std::cout << "Tools:\n";
@@ -22,7 +22,7 @@ int main()
if (build_tool)
std::cout << "Build tool: " << build_tool.node().attribute("Filename").value() << "\n";
-//]
+// end::code[]
}
// vim:et
diff --git a/docs/samples/xpath_variables.cpp b/docs/samples/xpath_variables.cpp
index 52313bf..5affaef 100644
--- a/docs/samples/xpath_variables.cpp
+++ b/docs/samples/xpath_variables.cpp
@@ -1,38 +1,38 @@
-#include "pugixml.hpp"
-
-#include <iostream>
-#include <string>
-
-int main()
-{
- pugi::xml_document doc;
- if (!doc.load_file("xgconsole.xml")) return -1;
-
-//[code_xpath_variables
- // Select nodes via compiled query
- pugi::xpath_variable_set vars;
- vars.add("remote", pugi::xpath_type_boolean);
-
- pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
-
- vars.set("remote", true);
- pugi::xpath_node_set tools_remote = query_remote_tools.evaluate_node_set(doc);
-
- vars.set("remote", false);
- pugi::xpath_node_set tools_local = query_remote_tools.evaluate_node_set(doc);
-
- std::cout << "Remote tool: ";
- tools_remote[2].node().print(std::cout);
-
- std::cout << "Local tool: ";
- tools_local[0].node().print(std::cout);
-
- // You can pass the context directly to select_nodes/select_node
- pugi::xpath_node_set tools_local_imm = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
-
- std::cout << "Local tool imm: ";
- tools_local_imm[0].node().print(std::cout);
-//]
-}
-
-// vim:et
+#include "pugixml.hpp"
+
+#include <iostream>
+#include <string>
+
+int main()
+{
+ pugi::xml_document doc;
+ if (!doc.load_file("xgconsole.xml")) return -1;
+
+// tag::code[]
+ // Select nodes via compiled query
+ pugi::xpath_variable_set vars;
+ vars.add("remote", pugi::xpath_type_boolean);
+
+ pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
+
+ vars.set("remote", true);
+ pugi::xpath_node_set tools_remote = query_remote_tools.evaluate_node_set(doc);
+
+ vars.set("remote", false);
+ pugi::xpath_node_set tools_local = query_remote_tools.evaluate_node_set(doc);
+
+ std::cout << "Remote tool: ";
+ tools_remote[2].node().print(std::cout);
+
+ std::cout << "Local tool: ";
+ tools_local[0].node().print(std::cout);
+
+ // You can pass the context directly to select_nodes/select_node
+ pugi::xpath_node_set tools_local_imm = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
+
+ std::cout << "Local tool imm: ";
+ tools_local_imm[0].node().print(std::cout);
+// end::code[]
+}
+
+// vim:et
diff --git a/readme.txt b/readme.txt
index 54d2a6c..faa41d3 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,6 +1,6 @@
-pugixml 1.5 - an XML processing library
+pugixml 1.6 - an XML processing library
-Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
Report bugs and download new versions at http://pugixml.org/
This is the distribution of pugixml, which is a C++ XML processing library,
@@ -28,7 +28,7 @@ The distribution contains the following folders:
This library is distributed under the MIT License:
-Copyright (c) 2006-2014 Arseny Kapoulkine
+Copyright (c) 2006-2015 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index daf6b35..6270ae5 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -22,7 +22,7 @@ else()
add_library(pugixml STATIC ${SOURCES})
endif()
-set_target_properties(pugixml PROPERTIES VERSION 1.5 SOVERSION 1)
+set_target_properties(pugixml PROPERTIES VERSION 1.6 SOVERSION 1)
install(TARGETS pugixml EXPORT pugixml-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp
index 6219dbe..5ee5131 100644
--- a/src/pugiconfig.hpp
+++ b/src/pugiconfig.hpp
@@ -1,7 +1,7 @@
/**
- * pugixml parser - version 1.5
+ * pugixml parser - version 1.6
* --------------------------------------------------------
- * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at http://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -46,7 +46,7 @@
#endif
/**
- * Copyright (c) 2006-2014 Arseny Kapoulkine
+ * Copyright (c) 2006-2015 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 41175ad..251ba7f 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -1,7 +1,7 @@
/**
- * pugixml parser - version 1.5
+ * pugixml parser - version 1.6
* --------------------------------------------------------
- * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at http://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -4059,61 +4059,28 @@ PUGI__NS_BEGIN
if (node->first_attribute)
node_output_attributes(writer, node, flags);
- if (flags & format_raw)
+ if (!node->first_child)
{
- if (!node->first_child)
- writer.write(' ', '/', '>');
- else
- {
- writer.write('>');
+ writer.write(' ', '/', '>');
- return true;
- }
+ return false;
}
else
{
- xml_node_struct* first = node->first_child;
-
- if (!first)
- writer.write(' ', '/', '>', '\n');
- else if (!first->next_sibling && (PUGI__NODETYPE(first) == node_pcdata || PUGI__NODETYPE(first) == node_cdata))
- {
- writer.write('>');
-
- const char_t* value = first->contents ? first->contents + 0 : PUGIXML_TEXT("");
-
- if (PUGI__NODETYPE(first) == node_pcdata)
- text_output(writer, value, ctx_special_pcdata, flags);
- else
- text_output_cdata(writer, value);
-
- writer.write('<', '/');
- writer.write_string(name);
- writer.write('>', '\n');
- }
- else
- {
- writer.write('>', '\n');
+ writer.write('>');
- return true;
- }
+ return true;
}
-
- return false;
}
- PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags)
+ PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node)
{
const char_t* default_name = PUGIXML_TEXT(":anonymous");
const char_t* name = node->contents ? node->contents : default_name;
writer.write('<', '/');
writer.write_string(name);
-
- if (flags & format_raw)
- writer.write('>');
- else
- writer.write('>', '\n');
+ writer.write('>');
}
PUGI__FN void node_output_simple(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags)
@@ -4124,17 +4091,14 @@ PUGI__NS_BEGIN
{
case node_pcdata:
text_output(writer, node->contents ? node->contents + 0 : PUGIXML_TEXT(""), ctx_special_pcdata, flags);
- if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_cdata:
text_output_cdata(writer, node->contents ? node->contents + 0 : PUGIXML_TEXT(""));
- if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_comment:
node_output_comment(writer, node->contents ? node->contents + 0 : PUGIXML_TEXT(""));
- if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_pi:
@@ -4148,7 +4112,6 @@ PUGI__NS_BEGIN
}
writer.write('?', '>');
- if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_declaration:
@@ -4156,7 +4119,6 @@ PUGI__NS_BEGIN
writer.write_string(node->contents ? node->contents : default_name);
node_output_attributes(writer, node, flags);
writer.write('?', '>');
- if ((flags & format_raw) == 0) writer.write('\n');
break;
case node_doctype:
@@ -4170,7 +4132,6 @@ PUGI__NS_BEGIN
}
writer.write('>');
- if ((flags & format_raw) == 0) writer.write('\n');
break;
default:
@@ -4178,9 +4139,16 @@ PUGI__NS_BEGIN
}
}
+ enum indent_flags_t
+ {
+ indent_newline = 1,
+ indent_indent = 2
+ };
+
PUGI__FN void node_output(xml_buffered_writer& writer, xml_node_struct* root, const char_t* indent, unsigned int flags, unsigned int depth)
{
size_t indent_length = ((flags & (format_indent | format_raw)) == format_indent) ? strlength(indent) : 0;
+ unsigned int indent_flags = indent_indent;
xml_node_struct* node = root;
@@ -4189,29 +4157,47 @@ PUGI__NS_BEGIN
assert(node);
// begin writing current node
- if (indent_length)
- text_output_indent(writer, indent, indent_length, depth);
+ if (PUGI__NODETYPE(node) == node_pcdata || PUGI__NODETYPE(node) == node_cdata)
+ {
+ node_output_simple(writer, node, flags);
- if (PUGI__NODETYPE(node) == node_element)
+ indent_flags = 0;
+ }
+ else
{
- if (node_output_start(writer, node, flags))
+ if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
+ writer.write('\n');
+
+ if ((indent_flags & indent_indent) && indent_length)
+ text_output_indent(writer, indent, indent_length, depth);
+
+ if (PUGI__NODETYPE(node) == node_element)
{
- node = node->first_child;
- depth++;
- continue;
+ indent_flags = indent_newline | indent_indent;
+
+ if (node_output_start(writer, node, flags))
+ {
+ node = node->first_child;
+ depth++;
+ continue;
+ }
}
- }
- else if (PUGI__NODETYPE(node) == node_document)
- {
- if (node->first_child)
+ else if (PUGI__NODETYPE(node) == node_document)
{
- node = node->first_child;
- continue;
+ indent_flags = indent_indent;
+
+ if (node->first_child)
+ {
+ node = node->first_child;
+ continue;
+ }
+ }
+ else
+ {
+ node_output_simple(writer, node, flags);
+
+ indent_flags = indent_newline | indent_indent;
}
- }
- else
- {
- node_output_simple(writer, node, flags);
}
// continue to the next node
@@ -4230,14 +4216,22 @@ PUGI__NS_BEGIN
{
depth--;
- if (indent_length)
+ if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
+ writer.write('\n');
+
+ if ((indent_flags & indent_indent) && indent_length)
text_output_indent(writer, indent, indent_length, depth);
- node_output_end(writer, node, flags);
+ node_output_end(writer, node);
+
+ indent_flags = indent_newline | indent_indent;
}
}
}
while (node != root);
+
+ if ((indent_flags & indent_newline) && (flags & format_raw) == 0)
+ writer.write('\n');
}
PUGI__FN bool has_declaration(xml_node_struct* node)
@@ -12171,7 +12165,7 @@ namespace pugi
#endif
/**
- * Copyright (c) 2006-2014 Arseny Kapoulkine
+ * Copyright (c) 2006-2015 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 9798b46..d59f864 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -1,7 +1,7 @@
/**
- * pugixml parser - version 1.5
+ * pugixml parser - version 1.6
* --------------------------------------------------------
- * Copyright (C) 2006-2014, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Copyright (C) 2006-2015, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at http://pugixml.org/
*
* This library is distributed under the MIT License. See notice at the end
@@ -13,7 +13,7 @@
#ifndef PUGIXML_VERSION
// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons
-# define PUGIXML_VERSION 150
+# define PUGIXML_VERSION 160
#endif
// Include user configuration file (this can define various configuration macros)
@@ -1341,7 +1341,7 @@ namespace std
#endif
/**
- * Copyright (c) 2006-2014 Arseny Kapoulkine
+ * Copyright (c) 2006-2015 Arseny Kapoulkine
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
diff --git a/tests/allocator.cpp b/tests/allocator.cpp
index 74bbf10..8ca0963 100644
--- a/tests/allocator.cpp
+++ b/tests/allocator.cpp
@@ -23,11 +23,11 @@
namespace
{
- const size_t PAGE_SIZE = 4096;
+ const size_t page_size = 4096;
size_t align_to_page(size_t value)
{
- return (value + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ return (value + page_size - 1) & ~(page_size - 1);
}
void* allocate_page_aligned(size_t size)
@@ -36,7 +36,7 @@ namespace
// We can't use malloc because of occasional problems with CW on CRT termination
static HANDLE heap = HeapCreate(0, 0, 0);
- void* result = HeapAlloc(heap, 0, size + PAGE_SIZE);
+ void* result = HeapAlloc(heap, 0, size + page_size);
return reinterpret_cast<void*>(align_to_page(reinterpret_cast<size_t>(result)));
}
@@ -45,13 +45,13 @@ namespace
{
size_t aligned_size = align_to_page(size);
- void* ptr = allocate_page_aligned(aligned_size + PAGE_SIZE);
+ void* ptr = allocate_page_aligned(aligned_size + page_size);
if (!ptr) return 0;
char* end = static_cast<char*>(ptr) + aligned_size;
DWORD old_flags;
- VirtualProtect(end, PAGE_SIZE, PAGE_NOACCESS, &old_flags);
+ VirtualProtect(end, page_size, PAGE_NOACCESS, &old_flags);
return end - size;
}
@@ -63,7 +63,7 @@ namespace
void* rptr = static_cast<char*>(ptr) + size - aligned_size;
DWORD old_flags;
- VirtualProtect(rptr, aligned_size + PAGE_SIZE, PAGE_NOACCESS, &old_flags);
+ VirtualProtect(rptr, aligned_size + page_size, PAGE_NOACCESS, &old_flags);
}
}
#elif defined(__APPLE__) || defined(__linux__)
@@ -71,28 +71,28 @@ namespace
namespace
{
- const size_t PAGE_SIZE = 4096;
+ const size_t page_size = 4096;
size_t align_to_page(size_t value)
{
- return (value + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ return (value + page_size - 1) & ~(page_size - 1);
}
void* allocate_page_aligned(size_t size)
{
- return mmap(0, size + PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ return mmap(0, size + page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
}
void* allocate(size_t size)
{
size_t aligned_size = align_to_page(size);
- void* ptr = allocate_page_aligned(aligned_size + PAGE_SIZE);
+ void* ptr = allocate_page_aligned(aligned_size + page_size);
if (!ptr) return 0;
char* end = static_cast<char*>(ptr) + aligned_size;
- int res = mprotect(end, PAGE_SIZE, PROT_NONE);
+ int res = mprotect(end, page_size, PROT_NONE);
assert(res == 0);
(void)!res;
@@ -105,7 +105,7 @@ namespace
void* rptr = static_cast<char*>(ptr) + size - aligned_size;
- int res = mprotect(rptr, aligned_size + PAGE_SIZE, PROT_NONE);
+ int res = mprotect(rptr, aligned_size + page_size, PROT_NONE);
assert(res == 0);
(void)!res;
}
diff --git a/tests/archive.pl b/tests/archive.pl
index 0a03b23..76484f7 100644
--- a/tests/archive.pl
+++ b/tests/archive.pl
@@ -2,11 +2,12 @@
use Archive::Tar;
use Archive::Zip;
+use File::Basename;
my $target = shift @ARGV;
my @sources = @ARGV;
-my $basedir = ($target =~ /^(.*)(\.zip|\.tar.gz|\.tgz)$/) ? "$1/" : '';
+my $basedir = basename($target, ('.zip', '.tar.gz', '.tgz')) . '/';
my $zip = $target =~ /\.zip$/;
my $arch = $zip ? Archive::Zip->new : Archive::Tar->new;
diff --git a/tests/data/truncation.xml b/tests/data/truncation.xml
index 9cdbe13..1b0e9a8 100644
--- a/tests/data/truncation.xml
+++ b/tests/data/truncation.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<!DOCTYPE _++ SYSTEM "weekly-utf-8.dtd">
-<!-- _++'___-_< -->
+<!DOCTYPE 週報 SYSTEM "weekly-utf-8.dtd">
+<!-- 週報サンプル -->
<mesh name="mesh_root">
<!-- here is a mesh node -->
some text
@@ -8,12 +8,12 @@
some more text
<node attr1="value1" attr2="value2" />
<node attr1="value2">
- <+%- __--="name" >__="value">-__%___-_-</+%->
+ <汉语 名字="name" 价值="value">世界有很多语言𤭢</汉语>
<innernode/>
</node>
- <___>
- <_>++"</_>
- <__>太__</__>
- </___>
+ <氏名>
+ <氏>山田</氏>
+ <名>太郎</名>
+ </氏名>
<?include somedata?>
-</mesh>
+</mesh> \ No newline at end of file
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index 49428f2..09d89d7 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -1010,7 +1010,7 @@ TEST(document_progressive_truncation)
char* buffer = new char[original_size];
- for (size_t i = 1; i < original_size; ++i)
+ for (size_t i = 1; i <= original_size; ++i)
{
char* truncated_data = buffer + original_size - i;
@@ -1022,7 +1022,7 @@ TEST(document_progressive_truncation)
bool result = doc.load_buffer_inplace(truncated_data, i);
// only eof is parseable
- CHECK((i >= 3325) ? result : !result);
+ CHECK((i == original_size) ? result : !result);
}
// fragment mode
@@ -1033,7 +1033,7 @@ TEST(document_progressive_truncation)
bool result = doc.load_buffer_inplace(truncated_data, i, parse_default | parse_fragment);
// some truncate locations are parseable - those that come after declaration, declaration + doctype, declaration + doctype + comment and eof
- CHECK(((i - 21) < 3 || (i - 66) < 3 || (i - 95) < 3 || i >= 3325) ? result : !result);
+ CHECK(((i - 21) < 3 || (i - 66) < 3 || (i - 95) < 3 || i == original_size) ? result : !result);
}
}
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp
index 1feed21..44b13e3 100644
--- a/tests/test_dom_modify.cpp
+++ b/tests/test_dom_modify.cpp
@@ -4,6 +4,11 @@
#include <string>
#include <math.h>
+#include <string.h>
+
+#ifdef __BORLANDC__
+using std::ldexpf;
+#endif
TEST_XML(dom_attr_assign, "<node/>")
{
@@ -101,15 +106,28 @@ TEST_XML(dom_attr_set_value_llong, "<node/>")
}
#endif
-TEST_XML(dom_attr_assign_large_number, "<node attr1='' attr2='' />")
+TEST_XML(dom_attr_assign_large_number_float, "<node attr='' />")
{
xml_node node = doc.child(STR("node"));
- node.attribute(STR("attr1")) = std::numeric_limits<float>::max();
- node.attribute(STR("attr2")) = std::numeric_limits<double>::max();
+ node.attribute(STR("attr")) = std::numeric_limits<float>::max();
- CHECK(test_node(node, STR("<node attr1=\"3.40282347e+038\" attr2=\"1.7976931348623157e+308\" />"), STR(""), pugi::format_raw) ||
- test_node(node, STR("<node attr1=\"3.40282347e+38\" attr2=\"1.7976931348623157e+308\" />"), STR(""), pugi::format_raw));
+ CHECK(test_node(node, STR("<node attr=\"3.40282347e+038\" />"), STR(""), pugi::format_raw) ||
+ test_node(node, STR("<node attr=\"3.40282347e+38\" />"), STR(""), pugi::format_raw));
+}
+
+TEST_XML(dom_attr_assign_large_number_double, "<node attr='' />")
+{
+ xml_node node = doc.child(STR("node"));
+
+ node.attribute(STR("attr")) = std::numeric_limits<double>::max();
+
+ // Borland C does not print double values with enough precision
+#ifdef __BORLANDC__
+ CHECK_NODE(node, STR("<node attr=\"1.7976931348623156e+308\" />"));
+#else
+ CHECK_NODE(node, STR("<node attr=\"1.7976931348623157e+308\" />"));
+#endif
}
TEST_XML(dom_node_set_name, "<node>text</node>")
@@ -1452,6 +1470,17 @@ TEST(dom_node_copy_declaration_empty_name)
CHECK_STRING(decl2.name(), STR(""));
}
+template <typename T> bool fp_equal(T lhs, T rhs)
+{
+ // Several compilers compare float/double values on x87 stack without proper rounding
+ // This causes roundtrip tests to fail, although they correctly preserve the data.
+#if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MWERKS__)
+ return memcmp(&lhs, &rhs, sizeof(T)) == 0;
+#else
+ return lhs == rhs;
+#endif
+}
+
TEST(dom_fp_roundtrip_min_max)
{
xml_document doc;
@@ -1459,16 +1488,16 @@ TEST(dom_fp_roundtrip_min_max)
xml_attribute attr = node.append_attribute(STR("attr"));
node.text().set(std::numeric_limits<float>::min());
- CHECK(node.text().as_float() == std::numeric_limits<float>::min());
+ CHECK(fp_equal(node.text().as_float(), std::numeric_limits<float>::min()));
attr.set_value(std::numeric_limits<float>::max());
- CHECK(attr.as_float() == std::numeric_limits<float>::max());
+ CHECK(fp_equal(attr.as_float(), std::numeric_limits<float>::max()));
attr.set_value(std::numeric_limits<double>::min());
- CHECK(attr.as_double() == std::numeric_limits<double>::min());
+ CHECK(fp_equal(attr.as_double(), std::numeric_limits<double>::min()));
node.text().set(std::numeric_limits<double>::max());
- CHECK(node.text().as_double() == std::numeric_limits<double>::max());
+ CHECK(fp_equal(node.text().as_double(), std::numeric_limits<double>::max()));
}
const double fp_roundtrip_base[] =
@@ -1492,11 +1521,13 @@ TEST(dom_fp_roundtrip_float)
float value = ldexpf(static_cast<float>(fp_roundtrip_base[i]), e);
doc.text().set(value);
- CHECK(doc.text().as_float() == value);
+ CHECK(fp_equal(doc.text().as_float(), value));
}
}
}
+// Borland C does not print double values with enough precision
+#ifndef __BORLANDC__
TEST(dom_fp_roundtrip_double)
{
xml_document doc;
@@ -1505,10 +1536,23 @@ TEST(dom_fp_roundtrip_double)
{
for (size_t i = 0; i < sizeof(fp_roundtrip_base) / sizeof(fp_roundtrip_base[0]); ++i)
{
+ #if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MWERKS__)
+ // Not all runtime libraries guarantee roundtripping for denormals
+ if (e == -1021 && fp_roundtrip_base[i] < 0.5)
+ continue;
+ #endif
+
+ #ifdef __DMC__
+ // Digital Mars C does not roundtrip on exactly one combination
+ if (e == -12 && i == 1)
+ continue;
+ #endif
+
double value = ldexp(fp_roundtrip_base[i], e);
doc.text().set(value);
- CHECK(doc.text().as_double() == value);
+ CHECK(fp_equal(doc.text().as_double(), value));
}
}
}
+#endif
diff --git a/tests/test_header_only.cpp b/tests/test_header_only.cpp
index f1990dd..17cafca 100644
--- a/tests/test_header_only.cpp
+++ b/tests/test_header_only.cpp
@@ -12,5 +12,8 @@ TEST(header_only)
xml_document doc;
CHECK(doc.load_string(STR("<node/>")));
CHECK_STRING(doc.first_child().name(), STR("node"));
+
+#ifndef PUGIXML_NO_XPATH
CHECK(doc.first_child() == doc.select_node(STR("//*")).node());
+#endif
}
diff --git a/tests/test_version.cpp b/tests/test_version.cpp
index 24036fc..cf64efc 100644
--- a/tests/test_version.cpp
+++ b/tests/test_version.cpp
@@ -1,5 +1,5 @@
#include "../src/pugixml.hpp"
-#if PUGIXML_VERSION != 150
+#if PUGIXML_VERSION != 160
#error Unexpected pugixml version
#endif
diff --git a/tests/test_write.cpp b/tests/test_write.cpp
index 59cdb3e..ad6c409 100644
--- a/tests/test_write.cpp
+++ b/tests/test_write.cpp
@@ -22,19 +22,19 @@ TEST_XML(write_indent, "<node attr='1'><child><sub>text</sub></child></node>")
TEST_XML(write_pcdata, "<node attr='1'><child><sub/>text</child></node>")
{
- CHECK_NODE_EX(doc, STR("<node attr=\"1\">\n\t<child>\n\t\t<sub />\n\t\ttext\n\t</child>\n</node>\n"), STR("\t"), format_indent);
+ CHECK_NODE_EX(doc, STR("<node attr=\"1\">\n\t<child>\n\t\t<sub />text</child>\n</node>\n"), STR("\t"), format_indent);
}
TEST_XML_FLAGS(write_cdata, "<![CDATA[value]]>", parse_cdata | parse_fragment)
{
CHECK_NODE(doc, STR("<![CDATA[value]]>"));
- CHECK_NODE_EX(doc, STR("<![CDATA[value]]>\n"), STR(""), 0);
+ CHECK_NODE_EX(doc, STR("<![CDATA[value]]>"), STR(""), 0);
}
TEST_XML_FLAGS(write_cdata_empty, "<![CDATA[]]>", parse_cdata | parse_fragment)
{
CHECK_NODE(doc, STR("<![CDATA[]]>"));
- CHECK_NODE_EX(doc, STR("<![CDATA[]]>\n"), STR(""), 0);
+ CHECK_NODE_EX(doc, STR("<![CDATA[]]>"), STR(""), 0);
}
TEST_XML_FLAGS(write_cdata_escape, "<![CDATA[value]]>", parse_cdata | parse_fragment)
@@ -123,7 +123,7 @@ TEST(write_pi_invalid)
node.set_name(STR("test"));
node.set_value(STR("?"));
- CHECK_NODE(doc, STR("<?test ?" "?>"));
+ CHECK_NODE(doc, STR("<?test ?") STR("?>"));
node.set_value(STR("?>"));
@@ -527,5 +527,50 @@ TEST(write_pcdata_null)
doc.first_child().append_child(node_pcdata);
- CHECK_NODE_EX(doc, STR("<node>\n\t\n\t\n</node>\n"), STR("\t"), format_indent);
+ CHECK_NODE_EX(doc, STR("<node></node>\n"), STR("\t"), format_indent);
+}
+
+TEST(write_pcdata_whitespace_fixedpoint)
+{
+ const char_t* data = STR("<node> test <child>\n <sub/>\n </child>\n</node>");
+
+ static const unsigned int flags_parse[] =
+ {
+ 0,
+ parse_ws_pcdata,
+ parse_ws_pcdata_single,
+ parse_trim_pcdata
+ };
+
+ static const unsigned int flags_format[] =
+ {
+ 0,
+ format_raw,
+ format_indent
+ };
+
+ for (unsigned int i = 0; i < sizeof(flags_parse) / sizeof(flags_parse[0]); ++i)
+ {
+ xml_document doc;
+ CHECK(doc.load_string(data, flags_parse[i]));
+
+ for (unsigned int j = 0; j < sizeof(flags_format) / sizeof(flags_format[0]); ++j)
+ {
+ std::string saved = write_narrow(doc, flags_format[j], encoding_auto);
+
+ xml_document rdoc;
+ CHECK(rdoc.load_buffer(&saved[0], saved.size(), flags_parse[i]));
+
+ std::string rsaved = write_narrow(rdoc, flags_format[j], encoding_auto);
+
+ CHECK(saved == rsaved);
+ }
+ }
+}
+
+TEST_XML_FLAGS(write_mixed, "<node><child1/><child2>pre<![CDATA[data]]>mid<!--comment--><test/>post<?pi value?>fin</child2><child3/></node>", parse_full)
+{
+ CHECK_NODE(doc, STR("<node><child1 /><child2>pre<![CDATA[data]]>mid<!--comment--><test />post<?pi value?>fin</child2><child3 /></node>"));
+ CHECK_NODE_EX(doc, STR("<node>\n<child1 />\n<child2>pre<![CDATA[data]]>mid<!--comment-->\n<test />post<?pi value?>fin</child2>\n<child3 />\n</node>\n"), STR("\t"), 0);
+ CHECK_NODE_EX(doc, STR("<node>\n\t<child1 />\n\t<child2>pre<![CDATA[data]]>mid<!--comment-->\n\t\t<test />post<?pi value?>fin</child2>\n\t<child3 />\n</node>\n"), STR("\t"), format_indent);
}
diff --git a/tests/writer_string.cpp b/tests/writer_string.cpp
index 661c792..26bca8d 100644
--- a/tests/writer_string.cpp
+++ b/tests/writer_string.cpp
@@ -45,7 +45,7 @@ std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi:
{
xml_writer_string writer;
- doc.save(writer, STR(""), flags, encoding);
+ doc.save(writer, STR("\t"), flags, encoding);
return writer.as_narrow();
}
@@ -59,7 +59,7 @@ std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_enco
{
xml_writer_string writer;
- node.print(writer, STR(""), flags, encoding);
+ node.print(writer, STR("\t"), flags, encoding);
return writer.as_narrow();
}
@@ -73,7 +73,7 @@ std::basic_string<wchar_t> write_wide(pugi::xml_node node, unsigned int flags, p
{
xml_writer_string writer;
- node.print(writer, STR(""), flags, encoding);
+ node.print(writer, STR("\t"), flags, encoding);
return writer.as_wide();
}