现在的位置: 首页 > 综合 > 正文

XPath简单介绍

2013年10月23日 ⁄ 综合 ⁄ 共 742字 ⁄ 字号 评论关闭

XML资料:

http://download1.csdn.net/down3/20070617/17213336933.pdf

code(XSL,XML之间的转换,等等)

 http://download1.csdn.net/down3/20070617/17215718922.rar

XmlDocument XDoc;
   XmlNodeList XNodes;

   XDoc = new XmlDocument();
   XDoc.Load(Server.MapPath("Orders.xml"));

   XNodes = XDoc.DocumentElement.SelectNodes("//Customer[starts-with(@Name,'A')]/Order");

   //以下没有使用缩略语法
//   XNodes = XDoc.DocumentElement.SelectNodes("descendant::Customer[start-with(attribute::Name,'A')]/child::Order");

   Response.Write("找到 "+XNodes.Count.ToString()+"个节点<br>");
   foreach(XmlNode XNode in XNodes)
   {
    Response.Write("Customer "+XNode.ParentNode.Attributes.GetNamedItem("Name").Value
     +" Ordered  "+XNode.Attributes.GetNamedItem("Quantity").Value
     +" "+XNode.InnerText+"<br>");
   } 

抱歉!评论已关闭.