?? 插入1.txt
字號:
using System.Data;
using System.Xml;
using System.IO;
private XmlDocument doc;
//插入節(jié)點
doc.Load("books.xml");
XmlElement newBook=doc.CreateElement("book");
newBook.SetAttribute("genre","Mystery");
newBook.SetAttribute("publicationdate","2001");
newBook.SetAttribute("ISBN","123456789");
//
XmlElement newTitle=doc.CreateElement("title");
newTitle.InnerText="Case of the Missing Cookie";
newBook.AppendChild(newTitle);
//
XmlElement newAuthor=doc.CreateElement("author");
newBook.AppendChild(newAuthor);
//
XmlElement newName=doc.CreateElement("name");
newName.InnerText="C.Monster";
newAuthor.AppendChild(newName);
//
XmlElement newPrice=doc.CreateElement("price");
newPrice.InnerText="9.95";
newBook.AppendChild(newPrice);
//
doc.DocumentElement.AppendChild(newBook);
//
XmlTextWriter tr=new XmlTextWriter("booksedit.xml",null);
tr.Formatting=Formatting.Indented;
doc.WriteContentTo(tr);
tr.Close();
XmlNodeList nodeLst=doc.GetElementsByTagName("title");
foreach(XmlNode node in nodeLst)
listBox1.Items.Add(node.InnerText);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -