This sample shows how to read and write an XML file to a directory. Basically this is like coping a file but using the XML Document Load and save functionality. APS.net 2.0
Imports System.DataImports System.XMLImports System.IOPartial Class LoadXMLFileWriteXML Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load WriteTXTFile() End Sub#Region " Read XML file and write it out " Sub WriteTXTFile() Try Dim XMLdoc As XmlDocument = New XmlDocument() XMLdoc.Load("C:\Website\XMLMadness\App_Data\USA.xml") 'Change this to your File location XMLdoc.Save("C:\Website\XMLMadness\App_Data\USA2.xml") 'Change this to your File location Label1.Text = "XML File Written" Catch xmlex As XmlException Console.WriteLine("{0}", xmlex.Message) Catch ex As Exception Console.WriteLine("{0}", ex.Message) End Try End Sub#End RegionEnd Class
Download Files:USA.xml