C#高級編程:使用XPath命名空間中的類[1]

發表于:2008-05-15來源:作者:點擊數: 標簽:XPath空間高級
關鍵字: .net 要理解這些類的用法,最好是查看一下迭代books.xml文檔的代碼,確定導航是如何工作的。為了使用這些示例,首先需要添加對System.Xml.Xsl 和 System.Xml. XP ath命名空間的引用,如下所示: using System.Xml.XPath; using System.Xml.Xsl; 這個
關鍵字:.net

    要理解這些類的用法,最好是查看一下迭代books.xml文檔的代碼,確定導航是如何工作的。為了使用這些示例,首先需要添加對System.Xml.Xsl 和 System.Xml.XPath命名空間的引用,如下所示:
    using System.Xml.XPath;
    using System.Xml.Xsl;

    這個示例使用了文件booksxpath.xml,它類似于前面使用的books.xml,但booksxpath.xml添加了兩本書。下面是窗體代碼,這段代碼在XPathXSLSample1文件夾中:
    private void button1_Click(object sender, System.EventArgs e)
    {
       //modify to match your path structure
       XPathDocument doc=new XPathDocument("..\\..\\..\\booksxpath.xml");
       //create the XPath navigator
       XPathNavigator nav=doc.CreateNavigator();
       //create the XPathNodeIterator of book nodes
       // that have genre attribute value of novel
       XPathNodeIterator iter=nav.Select("/bookstore/book[@genre='novel']"); 
     

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97