當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET XmlNode.SelectSingleNode方法代碼示例

本文整理匯總了VB.NET中System.Xml.XmlNode.SelectSingleNode方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlNode.SelectSingleNode方法的具體用法?VB.NET XmlNode.SelectSingleNode怎麽用?VB.NET XmlNode.SelectSingleNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。


在下文中一共展示了XmlNode.SelectSingleNode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Sample

' 導入命名空間
Imports System.IO
Imports System.Xml

Public Class Sample

  Public Shared Sub Main()

      Dim doc As XmlDocument = New XmlDocument()
      doc.Load("newbooks.xml")

      'Create an XmlNamespaceManager for resolving namespaces.
      Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(doc.NameTable)
      nsmgr.AddNamespace("bk", "urn:newbooks-schema")

      'Select the book written by an author whose last name is Atwood.
      Dim book As XmlNode 
      Dim root As XmlElement = doc.DocumentElement
      book = root.SelectSingleNode("descendant::bk:book[bk:author/bk:last-name='Atwood']", nsmgr)

      Console.WriteLine(book.OuterXml)

  End Sub
End Class
開發者ID:VB.NET開發者,項目名稱:System.Xml,代碼行數:24,代碼來源:XmlNode.SelectSingleNode

示例2: Sample

' 導入命名空間
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    'Create the XmlDocument.
    Dim doc as XmlDocument = new XmlDocument()
    doc.Load("booksort.xml")
           
    Dim book as XmlNode
    Dim root as XmlNode = doc.DocumentElement

    book=root.SelectSingleNode("descendant::book[author/last-name='Austen']")
 
    'Change the price on the book.
    book.LastChild.InnerText="15.95"

    Console.WriteLine("Display the modified XML document....")
    doc.Save(Console.Out)
    
  end sub
end class
開發者ID:VB.NET開發者,項目名稱:System.Xml,代碼行數:25,代碼來源:XmlNode.SelectSingleNode

示例3: Sample

' 導入命名空間
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

      Dim doc as XmlDocument = new XmlDocument()
      doc.Load("booksort.xml")

      'Create an XmlNamespaceManager for resolving namespaces.
      Dim nsmgr as XmlNamespaceManager = new XmlNamespaceManager(doc.NameTable)
      nsmgr.AddNamespace("bk", "urn:samples")

      'Select the book node with the matching attribute value.
      Dim book as XmlNode 
      Dim root as XmlElement = doc.DocumentElement
      book = root.SelectSingleNode("descendant::book[@bk:ISBN='1-861001-57-6']", nsmgr)

      Console.WriteLine(book.OuterXml)

  end sub
end class
開發者ID:VB.NET開發者,項目名稱:System.Xml,代碼行數:24,代碼來源:XmlNode.SelectSingleNode


注:本文中的System.Xml.XmlNode.SelectSingleNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。