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 有多少就输出多少

解决方案 »

  1.   

    DataSet可以直接读取XML;DataSet ds=new DataSet();
    ds.ReadXml();
    然后.. 哼哼..  ds里的值获取起来还不是手到擒来?
      

  2.   

    可以参考FortuneBase中的XmlBase参考地址www.cnblogs.com/mail-ricklee
      

  3.   

    用xml解析的,测试通过
            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;
      

  4.   

    <?xml version="1.0" encoding="utf-8"?>
    <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,应是上面那