libxml的使用(2)--读取节点属性
来源:互联网 发布:淘宝联盟pc端推广文案 编辑:程序博客网 时间:2024/05/23 11:59
在上一篇文章当中,我读取了各个节点的名字和内容,现在我将读取各个节点的属性。
- <?xml version="1.0" encoding="UTF-8"?>
- <root>
- <node1>content1</node1>
- <node2 attribute="yes">content2</node2>
- <node3>
- <subnode>go</subnode>
- </node3>
- </root>
这是上一篇文章中提到的xml文件。
在node2这个节点上有一个属性attribute,其值是yes。我们可以使用xmlGetProp这个函数将其提取出来。这个函数包含了两个变量,一个是将要提取属性的节点指针xmlNodePtr,另一个是属性的名称。
- xmlChar* attr_value = NULL;
- if(!xmlStrcmp(node->name, (const xmlChar*)"node2")) {
- attr_value = xmlGetProp(node, "attribute");
- printf("attribute value:%s\n",attr_value);
- xmlFree(attr_value);
- }
- libxml的使用(2)--读取节点属性
- libxml的使用(2)--读取节点属性
- libxml的使用(2)--读取节点属性
- libxml的使用(2)--读取节点属性
- libxml的使用(2)--读取节点属性 http://blog.csdn.net/hdutigerkin/article/details/7546907
- libxml的使用(2)--编辑节点
- libxml的使用(3)--编辑节点
- libxml的使用(3)--编辑节点
- libxml的使用(3)--编辑节点
- libxml的使用(3)--编辑节点
- libxml的使用(1)--读取xml
- libxml的使用(1)--读取xml
- libxml的使用(1)--读取xml
- libxml的使用(1)--读取xml
- libxml的使用(1)--读取xml
- libxml的使用(1)--读取xml
- libxml的使用(4)--xpath搜索节点树
- libxml的使用(4)--xpath搜索节点树
- (spring+hibernate)java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/Str
- Linux下的多进程编程
- 给button动态绑定click事件
- VC 四舍五入
- linux下socket编程示例
- libxml的使用(2)--读取节点属性
- 实际开发中LayoutInflater
- 黑马程序员-ADO.NET五大对象
- libxml的使用(3)--编辑节点
- OVM webservice 在winform中引用
- libxml的使用(4)--xpath搜索节点树
- linux中的延迟函数
- 岁月蹉跎,人生几何。
- 合成(Composite)模式