📄 default.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Load document
string booksFile = Path.Combine(Request.PhysicalApplicationPath, "books.xml");
XPathDocument document = new XPathDocument(booksFile);
XPathNavigator nav = document.CreateNavigator();
//Add a namespace prefix that can be used in the XPath expression
XmlNamespaceManager namespaceMgr = new XmlNamespaceManager(nav.NameTable);
namespaceMgr.AddNamespace("b", "http://example.books.com");
//All books whose price is not greater than 10.00
foreach (XPathNavigator node in
nav.Select("//b:book[not(b:price[. > 10.00])]/b:price",
namespaceMgr))
{
Decimal price = (decimal)node.ValueAs(typeof(decimal));
Response.Write(String.Format("Price is {0}<BR/>",
price));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -