Commit 1086074c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Rémi Denis-Courmont

dash: DOMHelper: Adding a helper to get the first child element.

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 1f722296
......@@ -40,6 +40,7 @@ std::vector<Node *> DOMHelper::getElementByTagName (Node *root, std::string
return elements;
}
std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, std::string name)
{
std::vector<Node *> elements;
......@@ -52,6 +53,7 @@ std::vector<Node *> DOMHelper::getChildElementByTagName (Node *root, std::string
return elements;
}
void DOMHelper::getElementsByTagName (Node *root, std::string name, std::vector<Node*> *elements, bool selfContain)
{
if(!selfContain && !root->getName().compare(name))
......@@ -68,3 +70,13 @@ void DOMHelper::getElementsByTagName (Node *root, std::string
getElementsByTagName(root->getSubNodes().at(i), name, elements, selfContain);
}
}
Node* DOMHelper::getFirstChildElementByName( Node *root, const std::string &name )
{
for(size_t i = 0; i < root->getSubNodes().size(); i++)
{
if( !root->getSubNodes().at( i )->getName().compare( name ) )
return root->getSubNodes().at( i );
}
return NULL;
}
......@@ -39,6 +39,7 @@ namespace dash
public:
static std::vector<Node *> getElementByTagName (Node *root, std::string name, bool selfContain);
static std::vector<Node *> getChildElementByTagName (Node *root, std::string name);
static Node* getFirstChildElementByName( Node *root, const std::string& name );
private:
static void getElementsByTagName(Node *root, std::string name, std::vector<Node *> *elements, bool selfContain);
......
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