From: Carl Hetherington Date: Wed, 24 May 2017 12:05:37 +0000 (+0100) Subject: Add node_children() method. X-Git-Tag: v0.15.5~5 X-Git-Url: https://git.carlh.net/gitweb/?p=libcxml.git;a=commitdiff_plain;h=9777a3cef3f434c5c9ba60161602a9305c705eb1 Add node_children() method. --- diff --git a/src/cxml.cc b/src/cxml.cc index 3248324..77770f9 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -73,6 +73,19 @@ cxml::Node::optional_node_child (string name) const return n.front (); } +list > +cxml::Node::node_children () const +{ + xmlpp::Node::NodeList c = _node->get_children (); + + list > n; + for (xmlpp::Node::NodeList::iterator i = c.begin (); i != c.end(); ++i) { + n.push_back (shared_ptr (new Node (*i))); + } + + return n; +} + list > cxml::Node::node_children (string name) const { diff --git a/src/cxml.h b/src/cxml.h index 2636ca0..b7f1ef5 100644 --- a/src/cxml.h +++ b/src/cxml.h @@ -200,6 +200,7 @@ public: boost::shared_ptr node_child (std::string) const; boost::shared_ptr optional_node_child (std::string) const; + std::list > node_children () const; std::list > node_children (std::string) const; xmlpp::Node* node () const {