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']");
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- Request.Cookies 和 Response.Cookies 的区别
- Spring.Net学习系列一: 统一异常处理
- 用OpenXml在文档的尾部添加一个Rich Text Content Con
- ASP.NET之Gridview图解(1)
- ASP.net页面中请求远程Web站点
- 向Excel文档中嵌入VBA控件和UserForm并显示
- ASP.NET生成高质量缩略图通用函数(c#代码)
- 使用ASP.NET MVC3+EF+Jquery制作文字直播系统(一
- 步步为营 SharePoint 开发学习笔记系列&nb
- ASP.NET FormsAuthentication跨站点登录时绝对地址返



