<?xml version="1.0" encoding="UTF-8"?>
<im apicode="1">
<sms>
<report mobile="0000000000" sm="1" code="0" desc="对"/>
<report mobile="0000000000" sm="2" code="0" desc="对"/>
<report mobile="0000000000" sm="3" code="0" desc="对"/>
<report mobile="0000000000" sm="4" code="0" desc="对"/>
</sms>
</im>//怎么通过循环获得每个mobile sm code desc的值啊
解决方案 »
- fckeditor 编辑器问题,有经验的朋友进来分享下
- 非哥 cloudgamer框架学习之Array function(){}() 这种使用感觉很抽象
- asp.net弹出新窗口
- 抢分题,回者有分
- 我从网上下载了个网站,在本地运行都正常,但是发布到网上就有错误
- 急救!~~~高手帮帮我啊!~~~~在DataList里用RadioButtonList动态绑定数据库
- vs2005 连接SQLSERVER2005 ,失败()急
- DataList编辑项中若干文本框和下拉框内容关联的问题!请高手赐教!入者有分~
- 為什麼動態生成的按鈕事件不能觸發? 控件是動態生成在 panell 中的!急急!!!
- 关于从存储过程返回参数是怎么用啊?
- 研究了一下,生成HTML的静态页
- ASP.NET XML实现搜索查询的相关功能
//这两种方法都可以。
DataSet ds = new DataSet();
ds.ReadXml(文件路径);
ds.Tables[0].Rows[][]
XmlDocument xd=new XmlDocument();
XmlDataDocument xdd=new XmlDataDocument();
xdd.Load();
xdd.DataSet.Tables[0]//...
List<string> pathList = new List<string>();
try
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode xn = doc.SelectSingleNode("im\sms");
XmlNodeList nodeList = xn.ChildNodes;
foreach (XmlNode xmlNode in nodeList)
{
pathList.Add( xmlNode.Attributes["mobile"].Value);
pathList.Add( xmlNode.Attributes["sm"].Value);
//同上,去属性就行了。。 }
}
catch { }List<string> 可以把这些属性放在一个类里面,List<类名> classList = new List<类名>();
classList.mobile = ... 一个个属性进行赋值就可以了
然后用下面的方法就可以获取属性值了 XmlDocument xmlDoc=new XmlDocument ();
xmlDoc.Load("D:/02.xml"); //假设你的xml文件在这
foreach (XmlNode node in xmlDoc.GetElementsByTagName("report"))
{
XmlAttribute mobile = node.Attributes["mobile"];
XmlAttribute sm = node.Attributes["sm"];
XmlAttribute code = node.Attributes["code"];
}