Save data in DataSet to xml file : DataSet XML « Database ADO.net « VB.Net Tutorial






Imports System.Data.SqlClient
Imports System.Data

Module Module1

    Sub Main()
        Try
            Dim DS As New DataSet()

            DS.ReadXml("Authors.XML")

            Dim XMLContent As String = DS.GetXml()

            Dim I As Integer

            For I = 0 To DS.Tables(0).Rows.Count - 1
                DS.Tables(0).Rows(I).Item("Author") = UCase(DS.Tables(0).Rows(I).Item("Author"))
            Next

            For I = 0 To DS.Tables(0).Rows.Count - 1
                Console.WriteLine(DS.Tables(0).Rows(I).Item("Title"))
                Console.WriteLine(DS.Tables(0).Rows(I).Item("Author"))
                Console.WriteLine(DS.Tables(0).Rows(I).Item("Publisher"))
                Console.WriteLine(DS.Tables(0).Rows(I).Item("Price"))
            Next

            DS.WriteXml("NewAuthors.xml")

            Console.ReadLine()

        Catch Ex As Exception
            Console.WriteLine("Exception: " & Ex.Message)
            Console.WriteLine(Ex.ToString)
        End Try

    End Sub

End Module








26.5.DataSet XML
26.5.1.Load XML data to DataSet
26.5.2.Save data in DataSet to xml file