本文整理匯總了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