本文整理汇总了VB.NET中System.Xml.XmlValidatingReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlValidatingReader.ReadString方法的具体用法?VB.NET XmlValidatingReader.ReadString怎么用?VB.NET XmlValidatingReader.ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了XmlValidatingReader.ReadString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Sample
' 导入命名空间
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim txtreader As XmlTextReader = Nothing
Dim reader As XmlValidatingReader = Nothing
Try
'Implement the readers.
txtreader = New XmlTextReader("elems.xml")
reader = New XmlValidatingReader(txtreader)
'Parse the XML and display the text content of each of the elements.
While reader.Read()
If reader.IsStartElement() Then
If reader.IsEmptyElement Then
Console.WriteLine("<{0}/>", reader.Name)
Else
Console.Write("<{0}> ", reader.Name)
reader.Read() 'Read the start tag.
If (reader.IsStartElement()) 'Handle nested elements.
Console.WriteLine()
Console.Write("<{0}>", reader.Name)
End If
Console.WriteLine(reader.ReadString()) 'Read the text content of the element.
End If
End If
End While
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub
End Class