下面的示例說明了如何使用ReadElementString()(這段代碼在XmlReaderSample
protected void button
{
//use a filestream to get the data
FileStream fs = new FileStream(
XmlTextReader tr = new XmlTextReader(fs);
while(!tr
{
//if we hit an element type
if(tr
{
listBox
}
else
{
//otherwise move on
tr
}
}
}
在while循環中
如果刪除了if子句中的&& tr
下面就調用這個新方法LoadList()
protected void button
{
//use a filestream to get the data
FileStream fs = new FileStream(
XmlTextReader tr = new XmlTextReader(fs);
while(!tr
{
//if we hit an element type
if(tr
{
LoadList(tr);
}
[
From:http://tw.wingwit.com/Article/program/net/201311/15182.html