c - 如何从 libxml2 中的节点获取属性

标签 c libxml2

我正在开发一个解析器来从 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/

相关文章:

c - scanf 和转换说明符的问题

c - 使用 libxml2 计算 XML 中具有相同名称的标签

objective-c - 为什么对libxml2 SAX解析的属性值中的实体进行编码?

c - libXML2 节点返回空

使用 libxml2 和 hpple 解析 iPhone html

c++ - 在嵌入式系统上将数组排序函数从 C++ 移植到 C

c++ - 在给定数组中找到每个元素出现两次的距离最长的元素?

c - 与 const 相同的地址和不同的值

c - 如何从 C 中的列主矩阵中提取 vector ?

xpath - xpath 'or'与xmllib2的行为类似union ('|')