使用libxml获取节点的所有属性的列表

Mar*_*ius 5 c xml libxml2

我很难找到一种方法来提取节点的所有属性的列表,而不知道它们被称为什么.

我使用以下方法提取单个已知属性:

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

但是如何使用libxml2获取所有属性的列表?

问候,marius

Rem*_*eau 12

只需循环遍历节点的属性列表,即:

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 ...
}
Run Code Online (Sandbox Code Playgroud)