⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.vb

📁 對c#初學者參考..為課題asp.net 2.0教材代碼
💻 VB
字号:
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
           Handles Me.Load
        'Load document
        Dim booksFile As String = Path.Combine(Request.PhysicalApplicationPath, _
            "books.xml")

        Dim document As New XmlDocument()
        document.Load(booksFile)
        Dim nav As XPathNavigator = document.CreateNavigator()

        'Add a namespace prefix that can be used in the XPath expression
        Dim namespaceMgr As New XmlNamespaceManager(nav.NameTable)
        namespaceMgr.AddNamespace("b", "http://example.books.com")

        'All books whose price is not greater than 10.00
        For Each node As XPathNavigator In nav.Select( _
                "//b:book[not(b:price[. > 10.00])]/b:price", namespaceMgr)
            Dim price As Decimal = CType(node.ValueAs(GetType(Decimal)), Decimal)
            node.SetTypedValue(price * CDec(1.2))
            Response.Write(String.Format("Price raised from {0} to {1}<BR/>", _
              price, _
              CType(node.ValueAs(GetType(Decimal)), Decimal)))
        Next


    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -