本文整理汇总了VB.NET中System.Xml.XmlTextReader.ReadChars方法的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlTextReader.ReadChars方法的具体用法?VB.NET XmlTextReader.ReadChars怎么用?VB.NET XmlTextReader.ReadChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.ReadChars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Sample
' 导入命名空间
Imports System.Xml
' Reads an XML document using ReadChars
Public Class Sample
Private Const filename As String = "items.xml"
Public Shared Sub Main()
Dim reader As XmlTextReader = Nothing
Try
' Declare variables used by ReadChars
Dim buffer() As Char
Dim iCnt As Integer = 0
Dim charbuffersize As Integer
' Load the reader with the data file. Ignore white space.
reader = New XmlTextReader(filename)
reader.WhitespaceHandling = WhitespaceHandling.None
' Set variables used by ReadChars.
charbuffersize = 10
buffer = New Char(charbuffersize) {}
' Parse the file. Read the element content
' using the ReadChars method.
reader.MoveToContent()
iCnt = reader.ReadChars(buffer,0,charbuffersize)
while (iCnt > 0)
' Print out chars read and the buffer contents.
Console.WriteLine(" Chars read to buffer:" & iCnt)
Console.WriteLine(" Buffer: [{0}]", New String(buffer, 0, iCnt))
' Clear the buffer.
Array.Clear(buffer, 0, charbuffersize)
iCnt = reader.ReadChars(buffer,0,charbuffersize)
end while
Finally
If Not (reader Is Nothing) Then
reader.Close()
End If
End Try
End Sub
End Class