Listing all node properties with libxml

I find it difficult to find a way to retrieve a list of all node properties without knowing what they cause.

I extract one of the known properties using:

xmlGetProp(cur, (const xmlChar*)"nodename")

But how to get a list of all properties using libxml2?

Regards, Marius

+5
source share
2 answers

Just go through the node property list, i.e.:

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 ...
}
+12
source

Interestingly, this is not a method that does this (although, oddly enough, the xmlFreePropList function), but the xmlNode structure has a pointer to a list of node properties (attributes). You can probably get a pointer to this structure.

0
source

All Articles