From d8c19b201f93dc070fb37472f933b53e49b393bc Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Mon, 18 Oct 2010 18:27:13 +0000 Subject: Added xml_document::document_element function git-svn-id: http://pugixml.googlecode.com/svn/trunk@768 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 9 +++++++++ src/pugixml.hpp | 3 +++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 1142930..f53ce1d 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4595,6 +4595,15 @@ namespace pugi return true; } + xml_node xml_document::document_element() const + { + for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) + if ((i->header & xml_memory_page_type_mask) + 1 == node_element) + return xml_node(i); + + return xml_node(); + } + #ifndef PUGIXML_NO_STL std::string PUGIXML_FUNCTION as_utf8(const wchar_t* str) { diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 9b0d0d6..81fc6c3 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -764,6 +764,9 @@ namespace pugi // Save XML to file bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; + + // Get document element + xml_node document_element() const; }; #ifndef PUGIXML_NO_XPATH -- cgit v1.2.3