<?xml version="1.0" encoding="utf-8" ?>
<warnlist count="2" lastnumber="2">
<warn number="1" nvsid="2001181" type="31" datetime="2013-08-19 17:32:01">2001181-无视频信号</warn>
<warn number="2" nvsid="2001182" type="31" datetime="2013-08-19 17:32:13">2001182-无视频信号</warn>
</warnlist>
http://stackoverflow.com/questions/3812277/how-to-display-data-from-xml-file-to-listview-using-linq-to-xml
XML反序列化为对象,也是一种思路~
当然LinqToXML也挺好的~
XmlDocument xml = new XmlDocument();
var xmlStr = File.ReadAllText("nvs_warn.xml");
xml.LoadXml(xmlStr);
var node = xml.SelectSingleNode("warnlist");
var names = new List<string>();
foreach (XmlNode studentNode in node.ChildNodes)
{
listView1.Items.Add(studentNode.InnerText);
}