tags:

views:

275

answers:

2

Hi,

I'm having 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

A: 

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.

Francis Upton
+2  A: 

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 ...
}
Remy Lebeau - TeamB