How to read an XML file to DataSet
Step 1
To read an XML file to a DataSet, first of all you need to declare a dataset first and then use the method called ReadXML to read your XML file to your dataset
Step 2
Create a datagrid and a button on your form. Then use the following code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New DataSet("Product")
ds.ReadXml("c:\product2.xml")
With DataGrid1
.DataSource = ds
End With
End Sub
Step 3
This will create a Dataset and then use it’s method of ReadXML to get data from your file. Then associate your dataset to datagrid.
An example of the screen output from the code above is shown below:
No comments:
Post a Comment