我的代碼有什麼問題?C#xml讀取,顯示錯誤
XmlTextReader textReader = new XmlTextReader(@"D:\xml_file.xml");
textReader.Read();
// If the node has value
while (textReader.Read())
{
// Move to fist element
textReader.MoveToElement();
Console.WriteLine("XmlTextReader Properties Test");
Console.WriteLine("===================");
// Read this element's properties and display them on console
Console.WriteLine("id:" + textReader.id.ToString());
Console.WriteLine("name:" + textReader.name.ToString());
Console.WriteLine("time:" + textReader.time.ToString());
}
Console.ReadLine()
展上erron:ID,姓名,時間
我的XML文件:
<students>
<student>
<id>1</id>
<name>Rikko Nora</name>
<time>2010-03-12</time>
</student>
<student>
<id>2</id>
<name>Rikko Nora2</name>
<time>2010-05-15</time>
</student>
</students>
什麼是錯誤? – Rbacarin 2010-05-18 18:49:21