c#读取XML
1 遍历XML
C#代码
XmlDocument xmlDoc = new XmlDocument();
string xmlPath=System.AppDomain.CurrentDomain.BaseDirectory.ToString();
xmlDoc.Load(xmlPath+"/xml/test.xml");
XmlNode xn=xmlDoc.SelectSingleNode("MyNodeName");
XmlNodeList xnl=xn.ChildNodes;
foreach(XmlNode xnf in xnl)
{
XmlElement xe=(XmlElement)xnf;
XmlNodeList xnf1=xe.ChildNodes;
Response.Write(xnf1[0].Value);
}
XML文件