Reads the text contents of an element into a character buffer.
using System;
using System.Xml;
public class Sample {
private const String filename = "items.xml";
public static void Main() {
XmlTextReader reader = null;
try {
Char []buffer;
int iCnt = 0;
int charbuffersize;
reader = new XmlTextReader(filename);
reader.WhitespaceHandling = WhitespaceHandling.None;
charbuffersize = 10;
buffer = new Char[charbuffersize];
reader.MoveToContent();
while ( (iCnt = reader.ReadChars(buffer,0,charbuffersize)) > 0 ) {
Console.WriteLine (" Chars read to buffer:" + iCnt);
Console.WriteLine (" Buffer: [{0}]", new String(buffer,0,iCnt));
Array.Clear(buffer,0,charbuffersize);
}
}
finally {
if (reader!=null)
reader.Close();
}
}
}
Related examples in the same category