本文整理匯總了VB.NET中System.Xml.Linq.XNode.ReadFrom方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET XNode.ReadFrom方法的具體用法?VB.NET XNode.ReadFrom怎麽用?VB.NET XNode.ReadFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。
在下文中一共展示了XNode.ReadFrom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Program
' 導入命名空間
Imports System.Collections.Generic
Imports System.Linq
Imports System.Xml
Imports System.Xml.Linq
Module Program
Iterator Function StreamRootChildDoc(ByVal uri As String) As IEnumerable(Of XElement)
Using reader As XmlReader = XmlReader.Create(uri)
reader.MoveToContent()
' Parse the file and return each of the nodes.
While Not reader.EOF
If reader.NodeType = XmlNodeType.Element AndAlso reader.Name = "Child" Then
Dim el As XElement = TryCast(XElement.ReadFrom(reader), XElement)
If el IsNot Nothing Then Yield el
Else
reader.Read()
End If
End While
End Using
End Function
Sub Main(args As String())
Dim grandChildData As IEnumerable(Of String) =
From el In StreamRootChildDoc("Source.xml")
Where CInt(el.Attribute("Key")) > 1
Select CStr(el.Element("GrandChild"))
For Each str As String In grandChildData
Console.WriteLine(str)
Next
End Sub
End Module