首页 > 编程知识 正文

安卓属性和节点的区别,libxml2数据存储

时间:2023-05-05 17:41:07 阅读:153601 作者:937

在上一篇文章中,您已经阅读了每个节点的名称和内容,现在将阅读每个节点的属性。

3358 www.Sina.com/viewplaincopyprint? XML版本=' 1.0 '编码=' utf-8 '? root node1content1/node1node2attribute=' yes ' content2/node2node3subnode go/subnode/node3/root

这是上一篇文章中提到的xml文件。

名为node2的节点具有属性attribute,其值为yes。 可以使用名为xmlGetProp的函数进行提取。 此函数包含两个变量:要从中提取属性的节点指针xmlNodePtr和属性名称。

3358 www.Sina.com/viewplaincopyprint? xmlChar*attr_value=NULL; if (! xmlstrcmp(node2-name,) constxmlchar * (node2) ) attr_value=xmlgetprop ) node,' attribute ); printf(attributevalue:%sn (,attr_value ); xmlfree(attr_value ); }这样就提取了“yes”这个字符串!

转载于:https://www.cn blogs.com/fire 909090/p/6798152.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。