' --- Open a filepicker and let the user select a file
Dim s_filename As String
Dim myopenfiledialog As New OpenFileDialog
myopenfiledialog.ShowDialog()
s_filename = myopenfiledialog.FileName ' the file selected by the user
' --- Read the content of the xml file
Dim myxmldoc As Xml.XmlDataDocument
myxmldoc = New Xml.XmlDataDocument
myxmldoc.DataSet.ReadXml(s_filename)
' --- Get the data into a dataset
Dim mydataset As New DataSet
mydataset = myxmldoc.DataSet
' --- And bind it to the datagridview
' Reference the table number by name if you know it, or by number if not
DataGridView1.DataSource = mydataset.DefaultViewManager
DataGridView1.DataMember = mydataset.Tables(1).ToString
From dePoPo.net
How to import an XML file into a datagridview
Posted in:
Data Access
By dePoPo
Mar 21, 2009 - 1:36:23 PM
Mar 21, 2009 - 1:36:23 PM
This example shows how to import an XML file into a dataset object, and bind that object to a datagridview.
© Copyright 2010 by dePoPo.net