xml操作的一个问题.
xml源文件:
<book><ISBN>uy</ISBN></book>
代码:
FileStream fs = new FileStream("book.xml", FileMode.Open);
XmlReader reader = XmlReader.Create(fs);
reader.ReadStartElement("book");
reader.ReadToFollowing("ISBN");
do
{
Console.WriteLine(reader.ReadString());
} while (reader.ReadToNextSibling("ISBN"));
reader.ReadEndElement();
怎么会抛出exception:
Exception: 'None' is an invalid XmlNodeType. Line 1, position 29.
如果把xml改成:
<book>
<ISBN>uy</ISBN>
</book>
就不会了, 但是项目要求不允许这么做. 如何处理?