Code
1XmlDocument xdd = new XmlDocument();
2 xdd.Load(Server.MapPath("~/data/Book.xml"));//加载路径
3 XmlNode parent = xdd.SelectSingleNode("Books");//根节点
4 XmlNodeList child = parent.ChildNodes;//获取所有子节点
5 Response.Write(xdd.SelectSingleNode("Books/book").Attributes["author"].Value);//输出属性值
6 foreach (XmlNode node in child)//循环输出属性值和节点值
7 {
8 Response.Write(node.Attributes["id"].Value + " ");
9 Response.Write(node.SelectSingleNode("name").OuterXml+" ");
10 Response.Write(node.SelectSingleNode("price").OuterXml + " ");
11 Response.Write(node.SelectSingleNode("publish").OuterXml + "<br/>");
12 }
1XmlDocument xdd = new XmlDocument();
2 xdd.Load(Server.MapPath("~/data/Book.xml"));//加载路径
3 XmlNode parent = xdd.SelectSingleNode("Books");//根节点
4 XmlNodeList child = parent.ChildNodes;//获取所有子节点
5 Response.Write(xdd.SelectSingleNode("Books/book").Attributes["author"].Value);//输出属性值
6 foreach (XmlNode node in child)//循环输出属性值和节点值
7 {
8 Response.Write(node.Attributes["id"].Value + " ");
9 Response.Write(node.SelectSingleNode("name").OuterXml+" ");
10 Response.Write(node.SelectSingleNode("price").OuterXml + " ");
11 Response.Write(node.SelectSingleNode("publish").OuterXml + "<br/>");
12 }