<Url>http://www.baidu.com</Url>
</Folder>
<Url>http://www.sohu.com</Url>
</Folder>
</Favorites>
然后我读取所有Folder中的属性Name的值,将这些值保存至string[]当中。但我现在只能取到第一个Name和对应的值。
我的代码是这样的:
XmlReaderSettings settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
this.reader = XmlReader.Create(file, settings);
string folders = "";
this.reader.ReadToFollowing("Folder");
if (this.reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
folders += this.reader.Name + ":" + this.reader.Value + ";";
}
}
各位。告诉我怎么实现啊。谢谢了!