紧急问题,怎样读取文件中的内容。谢谢各位 用DataSet.ReadXML来读取这个文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1、Dataset.ReadXML()2、XmlDocument 装载到数据集里,然后从datatable里取值DataSet ds=new DataSet();StreamReader sr=new StreamReader(Application.StartupPath+"\\tt.xml",Encoding.GetEncoding("gb2312"));ds.ReadXml(sr,XmlReadMode.Auto); 能写得清楚点详细点吗?因为我没用过Dataset.ReadXML(),不知道怎么用~~谢谢啦 或者用XmlDocument来Select也可以 XmlDocument类, SelectSingleNode()方法 http://blog.csdn.net/lizanhong/archive/2004/06/23/24374.aspx http://blog.csdn.net/lizanhong/archive/2004/06/23/24374.aspx XmlDocument doc=new XmlDocument();doc.Load(@"e:\123.xml");XmlNode node=doc.SelectSingleNode("/ResourceConfig/NewSystemBranchGroup");foreach(XmlNode nodeChild in node.ChildNodes) Console.WriteLine(nodeChild.Attributes["Region"].Value); 这并不涉及数据库的应用,没有必要用到dataset,用xpathdocment最快代码段如下: using System;using System.Xml;using System.Xml.XPath;namespace ConsoleApplication2{ class Class1 { [STAThread] static void Main(string[] args) { XPathDocument doc=new XPathDocument("NewSystem.cfg"); XPathNavigator nav=doc.CreateNavigator(); XPathNodeIterator nods=nav.Select("//NewSystemBranchGroup"); while(nods.MoveNext()) { Console.Out.WriteLine(nods.Current.GetAttribute(nods.Current.LocalName,"CMB")); } } }} Tomgus(小桥流水) is right socket 为什么发送第一次成功 第二次 不成功呢??? 获取一个网站的查询信息 IIS程序下载速率问题 DataGridView中我想在某列中多添加一个控件怎么实现. 菜鸟问题 winCe 通信 installshield 10.5 中的问题????? 求个Web调用搜索引擎的实现 为什么我在Session_end中加了处理,但是就是不执行? for(i=pointIndex;i>0;i--)result/=10;for(i=pointIndex;i>0;i--,result/=10);区别在那? 想向delphi转C#的前辈讨教 一个困惑很久的问题
2、XmlDocument
DataSet ds=new DataSet();
StreamReader sr=new StreamReader(Application.StartupPath+"\\tt.xml",Encoding.GetEncoding("gb2312"));
ds.ReadXml(sr,XmlReadMode.Auto);
doc.Load(@"e:\123.xml");XmlNode node=doc.SelectSingleNode("/ResourceConfig/NewSystemBranchGroup");foreach(XmlNode nodeChild in node.ChildNodes)
Console.WriteLine(nodeChild.Attributes["Region"].Value);
代码段如下:
using System;
using System.Xml;
using System.Xml.XPath;namespace ConsoleApplication2
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
XPathDocument doc=new XPathDocument("NewSystem.cfg");
XPathNavigator nav=doc.CreateNavigator();
XPathNodeIterator nods=nav.Select("//NewSystemBranchGroup");
while(nods.MoveNext())
{
Console.Out.WriteLine(nods.Current.GetAttribute(nods.Current.LocalName,"CMB"));
}
}
}
}