6

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

Marius
  • 61
  • 1
  • 6

2 Answers2

14

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
  • 555,201
  • 31
  • 458
  • 770
0

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 IV
  • 19,322
  • 3
  • 53
  • 57