xml文件是这样的
<?xml version="1.0" encoding="utf-8"?>
<Map mapName="中文名" mapCode="英文名" mapWidth="1000" mapHeight="1000">
<tile>
<x="0" y="0" type="city" cityName="北京"/>
<x="1" y="0" type="wild" cityName="上海"/>
</tile>
</Map>要求读出 x,y,type,cityname 等属性的值 <x 有多少就输出多少
<?xml version="1.0" encoding="utf-8"?>
<Map mapName="中文名" mapCode="英文名" mapWidth="1000" mapHeight="1000">
<tile>
<x="0" y="0" type="city" cityName="北京"/>
<x="1" y="0" type="wild" cityName="上海"/>
</tile>
</Map>要求读出 x,y,type,cityname 等属性的值 <x 有多少就输出多少
解决方案 »
- 双网接入两个IP地址的使用
- .net MVC 没了ViewState,讨论一下类似的解决方案
- 求助:不重新发送信息,则无法刷新网页
- 页面中的calendar 控件更换月份时候,整个页面都刷新。苦恼!
- 通易erp软件 你们觉得怎么样?
- 十分有创意的一个问题:如何在我的项目启动时,系统自动运行一个线程,这个线程在项目的整个运行过程中一直存在并监测系统中的一些运行状
- 请问在SQL-SERVER2000中如何使用动态SQL语句?急!!!!
- 在使用gridview模板中有一个按钮,我单击按钮弹出一个层!
- DataGrid的分页问题?
- 一个有关引用Session的问题.
- union 分页
- 关于SQL 注入的结局方法(z360.net)
ds.ReadXml();
然后.. 哼哼.. ds里的值获取起来还不是手到擒来?
XmlDocument testXmlDocument = new XmlDocument();
testXmlDocument.Load(Server.MapPath("XMLFile.xml"));
XmlNodeList childList = testXmlDocument.SelectNodes("Map/tile/address");
for (int i = 0; i < childList.Count; i++)
{
string strXValue = childList.Item(i).Attributes["x"].Value;
string strYValue = childList.Item(i).Attributes["y"].Value;
string strTypeValue = childList.Item(i).Attributes["type"].Value;
string strCityNameValue = childList.Item(i).Attributes["cityName"].Value;
}
需要导入:using System.Xml;
<Map mapName="中文名" mapCode="英文名" mapWidth="1000" mapHeight="1000">
<tile>
<address x="0" y="0" type="city" cityName="北京">
</address>
<address x="1" y="0" type="wild" cityName="上海">
</address>
</tile>
</Map>
楼主写错了xml,应是上面那