AppendChild
[首頁] [教學] [安裝] [開發] [物件] [命名空間] [控制項] [函式] [資料庫] [檔案] [XML] [Office] [網站] [AJAX] [CSS] [問題] [技巧] [樣本] [參考] [示範程式] [待編] [網頁總覽]

首頁
向上

.NET Framework 類別庫 

XmlNode.AppendChild 方法

將指定的節點加入至這個節點之子節點清單的結尾。
 

Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument()
doc.LoadXml("<book>" & _
    " <title>ASP 2.0</title>" & _
    " <price>580</price>" & _
    "</book>")

' Create a new element node.
Dim newElem As System.Xml.XmlNode = doc.CreateNode("element", "publisher", "")
newElem.InnerText = "MyMaster"

Response.Write("Add the new element to the document...<br />")
Dim root As System.Xml.XmlElement = doc.DocumentElement
root.AppendChild(newElem)

' Save the document to a file and auto-indent the output.
Dim writer As System.Xml.XmlTextWriter = New System.Xml.XmlTextWriter(MapPath("App_Data\data.xml"), Nothing)
writer.Formatting = System.Xml.Formatting.Indented
doc.Save(writer)
writer.Close()
Response.Write("Save the document to a file data.xml and auto-indent the output.<br />")

資料來源:

r李明山 如意網站 ASP.NET 教學網