C#系统XML解析
C#微软开发的XML解析,需要引用一个命名空间:
using System.Xml;
其解析代码块如下:
#region SYSTEM.XML
XmlDocument doc = new XmlDocument();
doc.Load(Application.dataPath + "/Resources/XMLFile1.xml");
XmlNode node = doc.SelectSingleNode("root");
XmlNodeList nodeLIST = node.SelectNodes("server");
foreach (XmlElement item in nodeLIST)
{
print(item.SelectSingleNode("id").InnerText);
print(item.GetAttribute("port"));
}
#endregion