How to xml to DataGridView

XML, being an inherently platform-independent language, possesses the remarkable ability to transcend the boundaries of specific platforms, ensuring seamless compatibility and effortless data interchange across diverse environments. This extraordinary characteristic of XML empowers developers to utilize and use information stored in XML files on any other platform of their choosing, without encountering any compatibility issues or limitations.

XML to DataGridView

In the case of .Net technology, XML enjoys widespread support and recognition as a favored file format. The comprehensive integration of XML within the .Net ecosystem solidifies its position as a reliable and widely adopted means of storing and exchanging data. Developers can confidently rely on XML as a trusted and versatile format when working with .Net technologies.

To illustrate the practical implementation of XML data retrieval and utilization, consider the following source code snippet. This code demonstrates how to seamlessly load data from an XML file into a DataGridView, a popular data display component within .Net applications.

To accomplish this, a Dataset is utilized, employing an XmlReader to efficiently read the contents of the specified XML file, in this case, the Product.XML file.

Click here to download the input file product.xml

Full Source VB.NET
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

The first step involves locating the desired XML file using the capabilities provided by the XmlReader. Once successfully identified, the XmlReader is passed as an argument to the Dataset, establishing a seamless connection that enables the Dataset to accurately extract and process the XML content.

As the Dataset retrieves the data from the XML file, it conveniently serves as the data source for the DataGridView. This integration between the Dataset and the DataGridView ensures that the retrieved data is seamlessly presented and displayed within the DataGridView, offering a user-friendly and visually appealing interface to interact with the information contained in the XML file.


XML's platform independence empowers developers to effortlessly utilize XML-formatted data across various platforms. Within the .Net technology landscape, XML holds a prominent position as a widely supported file format. The provided source code snippet showcases how to efficiently load data from an XML file into a DataGridView using a Dataset, with the assistance of an XmlReader for reading the XML content. By using these powerful tools and techniques, developers can seamlessly retrieve, process, and display XML data within their .Net applications, enhancing user experiences and enabling efficient data management.