我正在开发一个解析器来从 XML 文件中获取数据。我正在使用 libxml2 来提取数据。我无法从节点获取属性。我只找到了 nb_attributes
来获取属性的计数。
最佳答案
我认为 joostk 的意思是 attribute->children,给出如下内容:
xmlAttr* attribute = node->properties;
while(attribute)
{
xmlChar* value = xmlNodeListGetString(node->doc, attribute->children, 1);
//do something with value
xmlFree(value);
attribute = attribute->next;
}
看看这是否适合您。
关于c - 如何从 libxml2 中的节点获取属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34740262/