试试看,
XmlDocument itemDoc = new XmlDocument();
itemDoc.Load("file.xml");
Console.WriteLine("DocumentElement has {0} children.",
itemDoc.DocumentElement.ChildNodes.Count);
foreach (XmlNode itemNode in itemDoc.DocumentElement.ChildNodes){
XmlElement itemElement = (XmlElement)itemNode;
Console.WriteLine("\n[Item]: {0}\n{1}",
itemElement.Attributes["name"].Value,
itemElement.Attributes["description"].Value);
if (itemNode.ChildNodes.Count == 0)
Console.WriteLine("(No additional Information)\n");
else
{
foreach (XmlNode childNode in itemNode.ChildNodes){
//
}
}
}