pugixml 1.2 manual | Overview | Installation | Document: Object model · Loading · Accessing · Modifying · Saving | XPath | API Reference | Table of Contents |

## 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` PUGIXML_WCHAR_MODE
- `#define` PUGIXML_NO_XPATH
- `#define` PUGIXML_NO_STL
- `#define` PUGIXML_NO_EXCEPTIONS
- `#define` PUGIXML_API
- `#define` PUGIXML_CLASS
- `#define` PUGIXML_FUNCTION
- `#define` PUGIXML_MEMORY_PAGE_SIZE
- `#define` PUGIXML_MEMORY_OUTPUT_STACK
- `#define` PUGIXML_MEMORY_XPATH_PAGE_SIZE
- `#define` PUGIXML_HEADER_ONLY

Types:

- `typedef` configuration-defined type`` char_t`;`
- `typedef` configuration-defined type`` string_t`;`
- `typedef void* (*`allocation_function`)(size_t size);`
- `typedef void (*`deallocation_function`)(void* ptr);`

Enumerations:

- `enum` xml_node_type
  - node_null
  - node_document
  - node_element
  - node_pcdata
  - node_cdata
  - node_comment
  - node_pi
  - node_declaration
  - node_doctype
- `enum` xml_parse_status
  - status_ok
  - status_file_not_found
  - status_io_error
  - status_out_of_memory
  - status_internal_error
  - status_unrecognized_tag
  - status_bad_pi
  - status_bad_comment
  - status_bad_cdata
  - status_bad_doctype
  - status_bad_pcdata
  - status_bad_start_element
  - status_bad_attribute
  - status_bad_end_element
  - status_end_element_mismatch
- `enum` xml_encoding
  - encoding_auto
  - encoding_utf8
  - encoding_utf16_le
  - encoding_utf16_be
  - encoding_utf16
  - encoding_utf32_le
  - encoding_utf32_be
  - encoding_utf32
  - encoding_wchar
  - encoding_latin1
- `enum` xpath_value_type
  - xpath_type_none
  - xpath_type_node_set
  - xpath_type_number
  - xpath_type_string
  - xpath_type_boolean

Constants:

- Formatting options bit flags:
  - format_default
  - format_indent
  - format_no_declaration
  - format_no_escapes
  - format_raw
  - format_save_file_text
  - format_write_bom
- Parsing options bit flags:
  - parse_cdata
  - parse_comments
  - parse_declaration
  - parse_default
  - parse_doctype
  - parse_eol
  - parse_escapes
  - parse_full
  - parse_minimal
  - parse_pi
  - parse_ws_pcdata
  - parse_ws_pcdata_single
  - parse_wconv_attribute
  - parse_wnorm_attribute

Classes:

- `class` xml_attribute
  - xml_attribute`();`
  - `bool` empty`() const;`
  - `operator` unspecified_bool_type`() const;`
  - `bool` operator==`(const xml_attribute& r) const;`
  - `bool` operator!=`(const xml_attribute& r) const;`
  - `bool` operator<`(const xml_attribute& r) const;`
  - `bool` operator>`(const xml_attribute& r) const;`
  - `bool` operator<=`(const xml_attribute& r) const;`
  - `bool` operator>=`(const xml_attribute& r) const;`
  - `size_t` hash_value`() const;`
  - `xml_attribute` next_attribute`() const;`
  - `xml_attribute` previous_attribute`() const;`
  - `const char_t*` name`() const;`
  - `const char_t*` value`() const;`
  - `const char_t*` as_string`(const char_t* def = "") const;`
  - `int` as_int`(int def = 0) const;`
  - `unsigned int` as_uint`(unsigned int def = 0) const;`
  - `double` as_double`(double def = 0) const;`
  - `float` as_float`(float def = 0) const;`
  - `bool` as_bool`(bool def = false) const;`
  - `bool` set_name`(const char_t* rhs);`
  - `bool` set_value`(const char_t* rhs);`
  - `bool` set_value`(int rhs);`
  - `bool` set_value`(unsigned int rhs);`
  - `bool` set_value`(double rhs);`
  - `bool` set_value`(bool rhs);`
  - `xml_attribute&` operator=`(const char_t* rhs);`
  - `xml_attribute&` operator=`(int rhs);`
  - `xml_attribute&` operator=`(unsigned int rhs);`
  - `xml_attribute&` operator=`(double rhs);`
  - `xml_attribute&` operator=`(bool rhs);`
- `class` xml_node
  - xml_node`();`
  - `bool` empty`() const;`
  - `operator` unspecified_bool_type`() const;`
  - `bool` operator==`(const xml_node& r) const;`
  - `bool` operator!=`(const xml_node& r) const;`
  - `bool` operator<`(const xml_node& r) const;`
  - `bool` operator>`(const xml_node& r) const;`
  - `bool` operator<=`(const xml_node& r) const;`
  - `bool` operator>=`(const xml_node& r) const;`
  - `size_t` hash_value`() const;`
  - `xml_node_type` type`() const;`
  - `const char_t*` name`() const;`
  - `const char_t*` value`() const;`
  - `xml_node` parent`() const;`
  - `xml_node` first_child`() const;`
  - `xml_node` last_child`() const;`
  - `xml_node` next_sibling`() const;`
  - `xml_node` previous_sibling`() const;`
  - `xml_attribute` first_attribute`() const;`
  - `xml_attribute` last_attribute`() const;`
  - implementation-defined type children`() const;`
  - implementation-defined type children`(const char_t* name) const;`
  - implementation-defined type attributes`() const;`
  - `xml_node` child`(const char_t* name) const;`
  - `xml_attribute` attribute`(const char_t* name) const;`
  - `xml_node` next_sibling`(const char_t* name) const;`
  - `xml_node` previous_sibling`(const char_t* name) const;`
  - `xml_node` find_child_by_attribute`(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;`
  - `xml_node` find_child_by_attribute`(const char_t* attr_name, const char_t* attr_value) const;`
  - `const char_t*` child_value`() const;`
  - `const char_t*` child_value`(const char_t* name) const;`
  - `xml_text` text`() const;`
  - `typedef xml_node_iterator` iterator`;`
  - `iterator` begin`() const;`
  - `iterator` end`() const;`
  - `typedef xml_attribute_iterator` attribute_iterator`;`
  - `attribute_iterator` attributes_begin`() const;`
  - `attribute_iterator` attributes_end`() const;`
  - `bool` traverse`(xml_tree_walker& walker);`
  - `template <typename Predicate> xml_attribute` find_attribute`(Predicate pred) const;`
  - `template <typename Predicate> xml_node` find_child`(Predicate pred) const;`
  - `template <typename Predicate> xml_node` find_node`(Predicate pred) const;`
  - `string_t` path`(char_t delimiter = '/') const;`
  - `xml_node` xml_node::first_element_by_path`(const char_t* path, char_t delimiter = '/') const;`
  - `xml_node` root`() const;`
  - `ptrdiff_t` offset_debug`() const;`
  - `bool` set_name`(const char_t* rhs);`
  - `bool` set_value`(const char_t* rhs);`
  - `xml_attribute` append_attribute`(const char_t* name);`
  - `xml_attribute` prepend_attribute`(const char_t* name);`
  - `xml_attribute` insert_attribute_after`(const char_t* name, const xml_attribute& attr);`
  - `xml_attribute` insert_attribute_before`(const char_t* name, const xml_attribute& attr);`
  - `xml_node` append_child`(xml_node_type type = node_element);`
  - `xml_node` prepend_child`(xml_node_type type = node_element);`
  - `xml_node` insert_child_after`(xml_node_type type, const xml_node& node);`
  - `xml_node` insert_child_before`(xml_node_type type, const xml_node& node);`
  - `xml_node` append_child`(const char_t* name);`
  - `xml_node` prepend_child`(const char_t* name);`
  - `xml_node` insert_child_after`(const char_t* name, const xml_node& node);`
  - `xml_node` insert_child_before`(const char_t* name, const xml_node& node);`
  - `xml_attribute` append_copy`(const xml_attribute& proto);`
  - `xml_attribute` prepend_copy`(const xml_attribute& proto);`
  - `xml_attribute` insert_copy_after`(const xml_attribute& proto, const xml_attribute& attr);`
  - `xml_attribute` insert_copy_before`(const xml_attribute& proto, const xml_attribute& attr);`
  - `xml_node` append_copy`(const xml_node& proto);`
  - `xml_node` prepend_copy`(const xml_node& proto);`
  - `xml_node` insert_copy_after`(const xml_node& proto, const xml_node& node);`
  - `xml_node` insert_copy_before`(const xml_node& proto, const xml_node& node);`
  - `bool` remove_attribute`(const xml_attribute& a);`
  - `bool` remove_attribute`(const char_t* name);`
  - `bool` remove_child`(const xml_node& n);`
  - `bool` remove_child`(const char_t* name);`
  - `void` 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` 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` print`(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;`
  - `xpath_node` select_single_node`(const char_t* query, xpath_variable_set* variables = 0) const;`
  - `xpath_node` select_single_node`(const xpath_query& query) const;`
  - `xpath_node_set` select_nodes`(const char_t* query, xpath_variable_set* variables = 0) const;`
  - `xpath_node_set` select_nodes`(const xpath_query& query) const;`
- `class` xml_document
  - xml_document`();`
  - `~`xml_document`();`
  - `void` reset`();`
  - `void` reset`(const xml_document& proto);`
  - `xml_parse_result` load`(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
  - `xml_parse_result` load`(std::wistream& stream, unsigned int options = parse_default);`
  - `xml_parse_result` load`(const char_t* contents, unsigned int options = parse_default);`
  - `xml_parse_result` load_file`(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
  - `xml_parse_result` load_file`(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
  - `xml_parse_result` load_buffer`(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
  - `xml_parse_result` load_buffer_inplace`(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
  - `xml_parse_result` load_buffer_inplace_own`(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);`
  - `bool` save_file`(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
  - `bool` save_file`(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
  - `void` save`(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
  - `void` save`(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;`
  - `void` save`(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;`
  - `xml_node` document_element`() const;`
- `struct` xml_parse_result
  - `xml_parse_status` status`;`
  - `ptrdiff_t` offset`;`
  - `xml_encoding` encoding`;`
  - `operator` bool`() const;`
  - `const char*` description`() const;`
- `class` xml_node_iterator
- `class` xml_attribute_iterator
- `class` xml_tree_walker
  - `virtual bool` begin`(xml_node& node);`
  - `virtual bool` for_each`(xml_node& node) = 0;`
  - `virtual bool` end`(xml_node& node);`
  - `int` depth`() const;`
- `class` xml_text
  - `bool` empty`() const;`
  - `operator` xml_text::unspecified_bool_type`() const;`
  - `const char_t*` xml_text::get`() const;`
  - `const char_t*` as_string`(const char_t* def = "") const;`
  - `int` as_int`(int def = 0) const;`
  - `unsigned int` as_uint`(unsigned int def = 0) const;`
  - `double` as_double`(double def = 0) const;`
  - `float` as_float`(float def = 0) const;`
  - `bool` as_bool`(bool def = false) const;`
  - `bool` set`(const char_t* rhs);`
  - `bool` set`(int rhs);`
  - `bool` set`(unsigned int rhs);`
  - `bool` set`(double rhs);`
  - `bool` set`(bool rhs);`
  - `xml_text&` operator=`(const char_t* rhs);`
  - `xml_text&` operator=`(int rhs);`
  - `xml_text&` operator=`(unsigned int rhs);`
  - `xml_text&` operator=`(double rhs);`
  - `xml_text&` operator=`(bool rhs);`
  - `xml_node` data`() const;`
- `class` xml_writer
  - `virtual void` write`(const void* data, size_t size) = 0;`
- `class` xml_writer_file`: public xml_writer`
  - xml_writer_file`(void* file);`
- `class` xml_writer_stream`: public xml_writer`
  - xml_writer_stream`(std::ostream& stream);`
  - xml_writer_stream`(std::wostream& stream);`
- `struct` xpath_parse_result
  - `const char*` error`;`
  - `ptrdiff_t` offset`;`
  - `operator` bool`() const;`
  - `const char*` description`() const;`
- `class` xpath_query
  - `explicit` xpath_query`(const char_t* query, xpath_variable_set* variables = 0);`
  - `bool` evaluate_boolean`(const xpath_node& n) const;`
  - `double` evaluate_number`(const xpath_node& n) const;`
  - `string_t` evaluate_string`(const xpath_node& n) const;`
  - `size_t` evaluate_string`(char_t* buffer, size_t capacity, const xpath_node& n) const;`
  - `xpath_node_set` evaluate_node_set`(const xpath_node& n) const;`
  - `xpath_value_type` return_type`() const;`
  - `const xpath_parse_result&` result`() const;`
  - `operator` unspecified_bool_type`() const;`
- `class` xpath_exception`: public std::exception`
  - `virtual const char*` what`() const throw();`
  - `const xpath_parse_result&` result`() const;`
- `class` xpath_node
  - xpath_node`();`
  - xpath_node`(const xml_node& node);`
  - xpath_node`(const xml_attribute& attribute, const xml_node& parent);`
  - `xml_node` node`() const;`
  - `xml_attribute` attribute`() const;`
  - `xml_node` parent`() const;`
  - `operator` unspecified_bool_type`() const;`
  - `bool` operator==`(const xpath_node& n) const;`
  - `bool` operator!=`(const xpath_node& n) const;`
- `class` xpath_node_set
  - xpath_node_set`();`
  - xpath_node_set`(const_iterator begin, const_iterator end, type_t type = type_unsorted);`
  - `typedef const xpath_node*` const_iterator`;`
  - `const_iterator` begin`() const;`
  - `const_iterator` end`() const;`
  - `const xpath_node&` operator[]`(size_t index) const;`
  - `size_t` size`() const;`
  - `bool` empty`() const;`
  - `xpath_node` first`() const;`
  - `enum type_t {`type_unsorted, type_sorted, type_sorted_reverse`};`
  - `type_t` type`() const;`
  - `void` sort`(bool reverse = false);`
- `class` xpath_variable
  - `const char_t*` name`() const;`
  - `xpath_value_type` type`() const;`
  - `bool` get_boolean`() const;`
  - `double` get_number`() const;`
  - `const char_t*` get_string`() const;`
  - `const xpath_node_set&` get_node_set`() const;`
  - `bool` set`(bool value);`
  - `bool` set`(double value);`
  - `bool` set`(const char_t* value);`
  - `bool` set`(const xpath_node_set& value);`
- `class` xpath_variable_set
  - `xpath_variable*` add`(const char_t* name, xpath_value_type type);`
  - `bool` set`(const char_t* name, bool value);`
  - `bool` set`(const char_t* name, double value);`
  - `bool` set`(const char_t* name, const char_t* value);`
  - `bool` set`(const char_t* name, const xpath_node_set& value);`
  - `xpath_variable*` get`(const char_t* name);`
  - `const xpath_variable*` get`(const char_t* name) const;`

Functions:

- `std::string` as_utf8`(const wchar_t* str);`
- `std::string` as_utf8`(const std::wstring& str);`
- `std::wstring` as_wide`(const char* str);`
- `std::wstring` as_wide`(const std::string& str);`
- `void` set_memory_management_functions`(allocation_function allocate, deallocation_function deallocate);`
- `allocation_function` get_memory_allocation_function`();`
- `deallocation_function` get_memory_deallocation_function`();`

pugixml 1.2 manual | Overview | Installation | Document: Object model · Loading · Accessing · Modifying · Saving | XPath | API Reference | Table of Contents |