@@ -890,6 +890,23 @@ virXMLChildElementCount(xmlNodePtr node)
return ret;
}
+/* Returns the number of node's properties, or -1 on error. */
+long
+virXMLPropertyCount(xmlNodePtr node)
+{
+ long ret = 0;
+ xmlAttrPtr cur = NULL;
+
+ if (!node || node->type != XML_ELEMENT_NODE)
+ return -1;
+ cur = node->properties;
+ while (cur) {
+ ret++;
+ cur = cur->next;
+ }
+ return ret;
+}
+
/**
* virXMLNodeToString: convert an XML node ptr to an XML string
@@ -72,6 +72,7 @@ int virXPathNodeSet(const char *xpath,
char * virXMLPropString(xmlNodePtr node,
const char *name);
long virXMLChildElementCount(xmlNodePtr node);
+long virXMLPropertyCount(xmlNodePtr node);
/* Internal function; prefer the macros below. */
xmlDocPtr virXMLParseHelper(int domcode,