Skip to content

Commit

Permalink
xml: Correctly find the first child element
Browse files Browse the repository at this point in the history
  • Loading branch information
beekhof committed Feb 23, 2017
1 parent 8e322e4 commit 16c59a4
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions include/crm/common/xml.h
Expand Up @@ -315,16 +315,34 @@ __xml_next(xmlNode * child)
return child;
}

static inline xmlNode *
__xml_first_child_element(xmlNode * parent)
{
xmlNode *child = NULL;

if (parent) {
child = parent->children;
}

while (child) {
if(child->type == XML_ELEMENT_NODE) {
return child;
}
child = child->next;
}
return NULL;
}

static inline xmlNode *
__xml_next_element(xmlNode * child)
{
if (child) {
while (child) {
child = child->next;
while (child && child->type != XML_ELEMENT_NODE) {
child = child->next;
if(child && child->type == XML_ELEMENT_NODE) {
return child;
}
}
return child;
return NULL;
}

void free_xml(xmlNode * child);
Expand Down

0 comments on commit 16c59a4

Please sign in to comment.