Option Explicit
Option Strict
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
'Create the XmlDocument.
Dim doc As New XmlDocument()
doc.LoadXml("" & _
"Pride And Prejudice " & _
" ")
'Create a new node and add it to the document.
'The text node is the content of the price element.
Dim elem As XmlElement = doc.CreateElement("price")
Dim text As XmlText = doc.CreateTextNode("19.95")
doc.DocumentElement.AppendChild(elem)
doc.DocumentElement.LastChild.AppendChild(text)
Console.WriteLine("Display the modified XML...")
'doc.Save(Console.Out)
'存檔
doc.Save("c:\price.xml")
End Sub 'Main
End Class 'Sample
資料來源: XmlDocument.CreateTextNode 方法 (System.Xml)參考文件:
VB.NET XML的基本使用
延伸閱讀: 使用word開啟網頁資料,可以將網頁下載存成WORD檔.
沒有留言:
張貼留言