File pacemaker-xml-find-first-child.patch of Package pacemaker.14737
commit 16c59a49aa7365412b9f7977021dc6ec7207125a
Author: Andrew Beekhof <andrew@beekhof.net>
Date: Thu Feb 23 14:41:02 2017 +1100
xml: Correctly find the first child element
diff --git a/include/crm/common/xml.h b/include/crm/common/xml.h
index a9489150e..9d9118a87 100644
--- a/include/crm/common/xml.h
+++ b/include/crm/common/xml.h
@@ -316,15 +316,33 @@ __xml_next(xmlNode * 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);