C#高级编程:使用XPath命名空间中的类[1]
来源:不详 责任编辑:admin 发表时间:2013-07-01 21:38 点击:次
关键字:.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']");
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- ASP.NET数据格式的Format--DataFormatString
- Pro ASP.NET MVC 3 Framework学习笔记之九
- 谈.Net委托与线程——创建无阻塞的异步调用(一
- 微软ASP.NET站点部署指南(11):部署SQL Server数据
- winform下通过webclient使用非流方式上传(post)数据和
- asp.net 六大内置对象(2)
- asp.net js模拟Button点击事件
- 教你如何来恢复一个丢失的数据文件
- MVC中一个表单实现多个提交按钮(一个action搞定
- Asp.net MVC源码分析--Model Validation(Client端)实现(2)