Commit d33a3b7d authored by louiz’'s avatar louiz’

XmlNode::get_children, to get a list of matching children instead of the first

parent 6bde78b5
......@@ -162,6 +162,17 @@ XmlNode* XmlNode::get_child(const std::string& name, const std::string& xmlns) c
return nullptr;
}
std::vector<XmlNode*> XmlNode::get_children(const std::string& name, const std::string& xmlns) const
{
std::vector<XmlNode*> res;
for (auto& child: this->children)
{
if (child->name == name && child->get_tag("xmlns") == xmlns)
res.push_back(child);
}
return res;
}
XmlNode* XmlNode::add_child(XmlNode* child)
{
child->parent = this;
......
......@@ -86,9 +86,13 @@ public:
*/
std::string get_tail() const;
/**
* Get a pointer to the first child element with that name
* Get a pointer to the first child element with that name and that xml namespace
*/
XmlNode* get_child(const std::string& name, const std::string& xmlns) const;
/**
* Get a vector of all the children that have that name and that xml namespace.
*/
std::vector<XmlNode*> get_children(const std::string& name, const std::string& xmlns) const;
/**
* Add a node child to this node. Assign this node to the child’s parent.
* Returns a pointer to the newly added child.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment