From 9777a3cef3f434c5c9ba60161602a9305c705eb1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 24 May 2017 13:05:37 +0100 Subject: Add node_children() method. --- src/cxml.cc | 13 +++++++++++++ src/cxml.h | 1 + 2 files changed, 14 insertions(+) (limited to 'src') 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 { -- cgit v1.2.3