最近做航空票务系统,需要对中航信的接口传来的xml进行分析。 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 } 转载于:https://www.cnblogs.com/youliny/archive/2009/09/09/1563172.html