前言:可延伸標記式語言(英語:eXtensible Markup Language,簡稱:XML),是一種標記式語言。標記指電腦所能理解的資訊符號,透過此種標記,電腦之間可以處理包含各種資訊的文章等。使用vb.net 輸出 XML 文件程式碼如下:
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檔.