<?xml version="1.0" encoding="utf-8" ?>
<shenhe>
<shenhes>
<value>1</value>
</shenhes>
</shenhe>
c# 读取xml中 单个的节点的值 如上面所示 如何读到那个1
请大大们 给我写详细点 什么引用啊 注释啊 我很笨 大家费心
<shenhe>
<shenhes>
<value>1</value>
</shenhes>
</shenhe>
c# 读取xml中 单个的节点的值 如上面所示 如何读到那个1
请大大们 给我写详细点 什么引用啊 注释啊 我很笨 大家费心
解决方案 »
- 怎么在后台取前台html控件的值(控件在gridview模板列中)
- asp.net如何访问动态生成的input type=file控件并实现点击asp:buttom上传???
- 在MVC 3.0下,用RAZOR写的页面,在FF下正常显示,IE不显示
- 请教.net文件的显示
- 超简单的代码,居然提示SQL Server 不存在或访问被拒绝。
- 高手请进:设置Configration的安全,但忘了给系统特殊权限,现启动不了Microsoft .NET Framework 1.1 配置
- 如何通过accessdatasource,gridview更新多个表。
- .NET 简易留言版系统设计
- 怎样将两个结构相同的DataSet数据集的数据合并,并按其中的一个字段排序
- 再问一下在“哪位大侠……”中提到的传个类组到数据库的问题!!
- asp.net gridview 获取选定行所在页的问题
- ASP.NET 如何后台进行判断是不是手机好吗
XmlDocument xml = new XmlDocument();
xml.Load(@"d:\test.xml");
XmlNode node = xml.SelectSingleNode("/shenhe/shenhes/value");
Response.Write(node.InnerText);
getelementBytag(“value”).innertext
xmlDoc.Load(@"文件路径");
Xmlnode node=xmlDoc.SelectSingleNode(@"/shenhe/shenhes/value");
输出:node.InnerXml;开头using System.Xml;
{
List<MarketProject.platform.modules.Information> list = new List<MarketProject.platform.modules.Information>();
//实例化xml
XmlDocument xml = new XmlDocument();
//读取xml文件
xml.Load(@"F:\\360data\\重要数据\\桌面\\Update_umis\\01.WebProject\\MarketProject\\et\\Test.xml"); //你的xml地址
string id = "";
string name = "";
string sex = "";
MarketProject.platform.modules.Information info = null;
//////////*******下面开始循环读取xml文件信息********/
///////////////
foreach (XmlNode node in xml.ChildNodes)
{
if (node.Name == "abc")
{
foreach (XmlNode node1 in node.ChildNodes)
{
if (node1.Name == "item")
{
foreach (XmlNode node2 in node1.ChildNodes)
{
switch (node2.Name)
{
case "id":
id = node2.InnerText;
break;
case "name":
name = node2.InnerText;
break;
default:
sex = node2.InnerText;
break;
}
}
info = new MarketProject.platform.modules.Information(id, name, sex);
//将信息保存至集合
list.Add(info);
}
}
}
}
GridView1.DataSource = list;
GridView1.DataBind();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;namespace MarketProject.platform.modules
{
public class Information
{
private string id;
public string Id
{
get { return id; }
set { id = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string sex;
public string Sex
{
get { return sex; }
set { sex = value; }
}
public Information()
{ }
public Information(string id, string name, string sex)
{
this.Id = id;
this.Name = name;
this.Sex = sex;
} }
}