从XML中读取数据

八万英尺 2011-12-08 05:51:07
<ArrayOfBasCzjbm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://Bestechsoft.com/">
<BasCzjbm>
<basClerkID xmlns="http://tempuri.org/">1</basClerkID>
<BasCode xmlns="http://tempuri.org/">super</BasCode>
<BasName xmlns="http://tempuri.org/">系统管理员</BasName>
<SuperYn xmlns="http://tempuri.org/">false</SuperYn>
<GroupAutoid xmlns="http://tempuri.org/" />
<PassWord xmlns="http://tempuri.org/">super</PassWord>
<Visible xmlns="http://tempuri.org/">false</Visible>
<DoorAutoid xmlns="http://tempuri.org/" />
<CreatID xmlns="http://tempuri.org/" />
<CreatTime xmlns="http://tempuri.org/">2011-12-08T14:30:07.640625+08:00</CreatTime>
<UpdateID xmlns="http://tempuri.org/" />
<UpdateTime xmlns="http://tempuri.org/">2011-12-08T14:30:07.640625+08:00</UpdateTime>
<DeleteID xmlns="http://tempuri.org/" />
<DeleteTime xmlns="http://tempuri.org/">2011-12-08T14:30:07.640625+08:00</DeleteTime>
<AppField1 xmlns="http://tempuri.org/" />
<AppField2 xmlns="http://tempuri.org/" />
<AppField3 xmlns="http://tempuri.org/" />
<Status xmlns="http://tempuri.org/">0</Status>
<Yx xmlns="http://tempuri.org/">false</Yx>
<BasShortCode xmlns="http://tempuri.org/" />
<BasPinyin xmlns="http://tempuri.org/" />
<LastOnlineTime xmlns="http://tempuri.org/">0001-01-01 00:00:00</LastOnlineTime>
<Online xmlns="http://tempuri.org/">false</Online>
</BasCzjbm>
</ArrayOfBasCzjbm>

在如上的一个XML中我要读取出<BasName xmlns="http://tempuri.org/">系统管理员</BasName> 里面的"系统管理员"这个值要怎么读?
...全文
78 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
dalmeeme 2011-12-08
  • 打赏
  • 举报
回复
		XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/test.xml"));
XmlNodeList nodes = xmlDoc.GetElementsByTagName("BasName");
foreach (XmlNode node in nodes)
Response.Write(node.InnerText);
八万英尺 2011-12-08
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dalmeeme 的回复:]

C# code
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/test.xml"));
XmlNode node = xmlDoc.GetElementsByTagName("BasName")[0];
Response.Write(no……
[/Quote]
不行呢..因为ArrayOfBasCzjbm节点里面可能有多个BasCzjbm节点..而且每一个BasName的值我都需要获取出来
黄瓜黄瓜 2011-12-08
  • 打赏
  • 举报
回复

[Quote=引用 1 楼 dalmeeme 的回复:]

C# code
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/test.xml"));
XmlNode node = xmlDoc.GetElementsByTagName("BasName")[0];
Response.Write(no……
[/Quote]
dalmeeme 2011-12-08
  • 打赏
  • 举报
回复
		XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/test.xml"));
XmlNode node = xmlDoc.GetElementsByTagName("BasName")[0];
Response.Write(node.InnerText);

xml文件路径你自己改一下。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧