如何在libxml2的节点获取属性 [英] How to get attributes from a node in libxml2

查看:683
本文介绍了如何在libxml2的节点获取属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个分析器,从XML文件中获取数据。我使用的libxml2提取数据。我是无法从节点获取的属性。我只找到<$​​ C $ C> nb_attributes 来获得属性的数量。

I am working on a parser to get data from an XML file. I am using libxml2 to extract data. I am a not able to get the attributes from nodes. I only found nb_attributes to get the count of the attributes.

推荐答案

我觉得joostk意味着属性 - >孩子,让这样的事情:

I think joostk meant attribute->children, giving something like this:

xmlAttr* attribute = node->properties;
while(attribute)
{
  xmlChar* value = xmlNodeListGetString(node->doc, attribute->children, 1);
  //do something with value
  xmlFree(value); 
  attribute = attribute->next;
}

看看是否能为你工作。

See if that works for you.

这篇关于如何在libxml2的节点获取属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆