1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2010-2013 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef RAPIDXML_UTIL_HPP
11 #define RAPIDXML_UTIL_HPP
15 #include <rapidxml.hpp>
17 class xml_doc : public rapidxml::xml_document<>
20 xml_doc(const char* xml)
22 // Make a copy because rapidxml destructs string
23 m_copy = new char[strlen(xml) + 1];
25 this->parse<0>(m_copy);
36 inline std::string get_attribute(rapidxml::xml_node<>* node, const char* name)
38 rapidxml::xml_attribute<> *attr = node->first_attribute(name);
42 value = attr->value();
47 inline void get_contents(rapidxml::xml_node<>* node, std::string& contents)
51 if (node->type() == rapidxml::node_element)
53 //std::cout << "ELEMENT: " << node->name() << "=" << node->value() << std::endl;
55 else if (node->type() == rapidxml::node_data)
57 contents += node->value();
58 //std::cout << "DATA: " << node->name() << "=" << node->value() << std::endl;
62 //std::cout << "OTHER: " << node->name() << "=" << node->value() << std::endl;
64 get_contents(node->first_node(), contents);
65 get_contents(node->next_sibling(), contents);
69 #endif // RAPIDXML_UTIL_HPP