Coding for window form:
Imports System.Xml
Imports System.Data
Public Class Form1
Dim ds As New DataSet
Dim dt As DataTable
Dim dt1 As DataTable
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
dt = New DataTable()
dt.Columns.Add(New DataColumn("Product_ID", Type.GetType("System.Int32")))
dt.Columns.Add(New DataColumn("Product_Name", Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("product_Price", Type.GetType("System.Int32")))
fillRows(1, "Note Book Pc", 1566)
fillRows(2, "Laptop", 26000)
fillRows(3, "Pc Computer", 13000)
fillRows(4, "Printer", 3999)
ds.Tables.Add(dt)
ds.Tables(0).TableName = "product"
ds.WriteXml("Product1.xml")
'Another xml file
MsgBox("First Product1.xml file fill to dataset")
Catch ex As Exception
End Try
End Sub
Private Sub fillRows(ByVal pID As Integer, ByVal pName As String, ByVal pPrice As Integer)
Dim dr As DataRow
dr = dt.NewRow()
dr("Product_ID") = pID
dr("Product_Name") = pName
dr("product_Price") = pPrice
dt.Rows.Add(dr)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim xmlFile As XmlReader
xmlFile = XmlReader.Create("Product1.xml", New XmlReaderSettings())
Dim ds As New DataSet
ds.ReadXml(xmlFile)
DataGridView1.DataSource = ds.Tables(0)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
dt1 = New DataTable()
dt1.Columns.Add(New DataColumn("Product_ID", Type.GetType("System.Int32")))
dt1.Columns.Add(New DataColumn("Product_Name", Type.GetType("System.String")))
dt1.Columns.Add(New DataColumn("product_Price", Type.GetType("System.Int32")))
fillRows(1, "Lux Shop", 15)
fillRows(2, "Hamam Shop", 26)
fillRows(3, "Detol Shop", 13)
fillRows(4, "Baby Johnsan", 39)
ds.Tables.Add(dt1)
ds.Tables(1).TableName = "product2"
ds.WriteXml("Product2.xml")
MsgBox("Second file Product2.xml fill to dataset")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim xmlFile As XmlReader
xmlFile = XmlReader.Create("Product2.xml", New XmlReaderSettings())
Dim ds As New DataSet
ds.ReadXml(xmlFile)
DataGridView2.DataSource = ds.Tables(0)
End Sub
End Class