嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
读写xml文件
doc = new XmlDocument();
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreComments = true;
string filepath = Environment.CurrentDirectory;
filepath = "\\book.xml";
XmlReader reader = XmlReader.Create(filepath, settings);
doc.Load(reader);
XmlNode xn = doc.SelectSingleNode("bookstore");
XmlNodeList xnl = xn.ChildNodes;
listView1.Items.Clear();
listView1.BeginUpdate();
foreach (XmlNode xnode in xnl)
{
xmlclass bookclass = new xmlclass();
XmlElement xe = (XmlElement)xnode;
bookclass.bookISBN = xe.GetAttribute("ISBN").ToString();
bookclass.bookType = xe.GetAttribute("Type").ToString();
XmlNodeList xnlist = xe.ChildNodes;
bookclass.bookName = xnlist.Item(0).InnerText;
bookclass.bookPrice = xnlist.Item(2).InnerText;
ListViewItem lvi = new ListViewItem();
lvi.Text = bookclass.bookISBN;
lvi.SubItems.Add(bookclass.bookType);
lvi.SubItems.Add(bookclass.bookName);
lvi.SubItems.Add(bookclass.bookPrice);
listView1.Items.Add(lvi);
}
listView1.EndUpdate();
reader.Close();