How to xml to DataGridView


VB.Net-Informations.com
SiteMap

XML is a platform independent language, so the information formatted in XML file can be use in any other platforms . The .Net technology is widely supported XML file format. The following source code shows , how to load data in a DataGridView from an XML file . Here the Dataset using an XmlReader for read the content of the XML file - Product.XML . Locate the XML file using XmlReader and pass the XmlReader as argument of Dataset. When the Dataset retrieves the data, it passes as DataSource to DataGridView .


Imports System.Xml
Imports System.Data
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim xmlFile As XmlReader
        xmlFile = XmlReader.Create("Product.xml", New XmlReaderSettings())
        Dim ds As New DataSet
        ds.ReadXml(xmlFile)
        DataGridView1.DataSource = ds.Tables(0)
    End Sub
End Class

Click here to download the input file product.xml


  • Sponsored Program







More Source Code :
|  Home  |   VB.NET  |   C#  |   ASP.NET  |   SiteMap  |   Terms of Use  |   About  |