c#读取xml中特定节点的值(实例)
来源:互联网 发布:标致pp2000软件 编辑:程序博客网 时间:2024/05/16 09:21
(转载请注明出处:http://blog.csdn.net/buptgshengod)
将要读取的是smoke下floortype中的value值,xml如下
<?xml version="1.0" encoding="UTF-8" ?> - <PropDataBucket name="navisworks_df_floor_cicle" version="1.0">- <PropDataRow name="smoke" index="0" type="custom">- <target name="properties"> <property name="floortype" value="circular" /> <property name="length" value="" /> </target> </PropDataRow>- <PropDataRow name="navisworks_df_floor_rectangular_01" index="1" type="">- <target name="properties"> <property name="floortype" value="rectangular" /> <property name="length" value="1000.00" /> </target> </PropDataRow> </PropDataBucket>
c#代码
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Xml;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { string str = ""; XmlDocument doc = new XmlDocument(); doc.Load(@"e:\test.xml");//读入xml,注意@ XmlNode node = doc.SelectSingleNode("//PropDataBucket/PropDataRow[@name='smoke']//property[@name='floortype']");//设置节点位置 if (node != null) { str = node.Attributes["value"].Value;//节点下多个数值名称的选择 } textBox1.Text = str; } }}
效果如图
0 0
- c#读取xml中特定节点的值(实例)
- C#读取xml特定节点实例
- C# 读取xml中特定节点的属性值 xmldocument方式
- C# 读取xml中特定节点的属性值 xmldocument方式 【有些乱,但有思路】
- C#之Xml文件特定节点的读取
- xml中如何读取一个子节点有特定值的节点
- C#读取xml节点的值
- C#中读取xml文件指定节点
- C#中读取xml文件指定节点
- C#中读取xml文件指定节点
- C#中读取xml文件指定节点
- c# 读取xml节点
- c# 读取xml节点 .
- C# 读取XML 节点
- C#读取XML节点
- 用C#读取XML指定节点下的值
- C# 读取与修改xml一个节点的值
- C# 读取与修改xml一个节点的值
- SQL avg(平均值)函数
- ACM 介绍
- oracle数据库导入导出cmd命令
- mvchtmlstring 自定义下拉列表
- c# xmlSerializer的使用示例
- c#读取xml中特定节点的值(实例)
- Window7/8 把笔记本配置成wifi热点
- make的那些事
- mysql中的substr()函数
- Web Service 服务安全漫谈
- Ext 中RadioGroup 监听事件 为什么只执行一次
- Extjs之访问store
- can not be represented as java.sql.Timestamp
- 手机号码和电话号码正则表达式