Getting list of all properties of a node using libxml
I'm h开发者_如何学编程aving trouble to find a way to extract a list of all properties of a node without knowing what they're called.
I'm extracting single known properties using:
xmlGetProp(cur, (const xmlChar*)"nodename")
But how to get a list of all properties using libxml2?
Regards, marius
Simply loop through the node's properties list, ie:
xmlNodePtr Node = ...;
for(xmlAttrPtr attr = Node->properties; NULL != attr; attr = attr->next)
{
... do something with attr ...
... the name of the attribute is in attr->name ...
}
Interesting, does not appear to be a method that does this (though oddly there is xmlFreePropList function), but the xmlNode structure has a pointer to a list of the properties (attributes) of the node. You can probably get a pointer to that structure.
精彩评论