private void button
{
//change path to match your structure
doc
//create a new
XmlElement newBook=doc
//set some attributes
newBook
newBook
newBook
//create a new
XmlElement newTitle=doc
newTitle
newBook
//create new author element
XmlElement newAuthor=doc
newBook
//create new name element
XmlElement newFTEL=doc
newName
newAuthor
//create new price element
XmlElement newPrice=doc
newPrice
newBook
//add to the current document
doc
//write out the doc to disk
XmlTextWriter tr=new XmlTextWriter(
tr
doc
tr
//load listBox
XmlNodeList nodeLst=doc
foreach(XmlNode node in nodeLst)
listBox
}
在執行這段代碼後
XmlElement newBook = doc
CreateElement()有
● 元素名
● 名稱和命名空間URI
● 前綴
創建了該元素後
newBook
newBook
newBook
創建了屬性後
XmlElement newTitle = doc
newTitle
newBook
再次創建一個新的基於XmlElement的對象(newTitle)
[
From:http://tw.wingwit.com/Article/program/net/201311/14750.html