操作xml
XmlDocument xd = new XmlDocument();
string xmlPath = Server.MapPath("default_menu.xml");
string xmlcon = string.Empty;
if (File.Exists(xmlPath))
{
StreamReader sr = File.OpenText(xmlPath);
xmlcon = sr.ReadToEnd();
}
xd.LoadXml(xmlcon);
XmlNode xn = xd.SelectSingleNode("Menu");
string xmlname = string.Empty;
if (xn.ChildNodes.Count > 0)
{
for (int i = 0; i < xn.ChildNodes.Count; i++)
{
xmlname += "<div><h2>" + xn.ChildNodes[i].Name + "</h2></div>";
if (xn.ChildNodes[i].ChildNodes.Count > 0)
{
for (int j = 0; j < xn.ChildNodes[i].ChildNodes.Count; j++)
{
xmlname += "<div>" + xn.ChildNodes[i].ChildNodes[j].Attributes["text"].Value + "</div><br/>";
}
}
}
}