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

This commit is contained in:
Florent Le Coz
2014-05-30 04:00:29 +02:00
parent 6bde78b574
commit d33a3b7d35
2 changed files with 16 additions and 1 deletions
+11
View File
@@ -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;