In this article I will explain with an example, how to read, parse and import XML file in Windows Forms DataGridView using C# and VB.Net.
The XML file will be read and parsed using a DataSet and all the records from the XML file will be imported into a DataTable within the DataSet.
Finally the DataSet will be used to populate and display the data from XML file in Windows Forms DataGridView.
The XML file
The following XML file will be used to populate the DataGridView.
<?xml version="1.0" standalone="yes"?>
    <Name>John Hammond</Name>
    <Country>United States</Country>
    <Name>Mudassar Khan</Name>
    <Name>Suzanne Mathews</Name>
    <Name>Robert Schidner</Name>
Form Controls
The following Form consists of a DataGridView and a Button to the Windows Form.
Read, Parse and Import XML file in Windows DataGridView using C# and VB.Net
You will need to import the following namespace.
using System.Data;
Imports System.Data
Populating DataGridView from XML file
Inside the Form Load event, first the XML file is selected using the OpenFileDialog control. Then using the path, the XML file is read into the DataSet using the ReadXml method.
Finally the DataSet is used to populate the DataGridView control.
private void btnSelect_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    if (openFileDialog.ShowDialog() == DialogResult.OK)
        string xmlFilePath = openFileDialog.FileName;
        using (DataSet ds = new DataSet())
            dataGridView1.DataSource = ds.Tables[0];
Private Sub btnSelect_Click(sender As System.Object, e As System.EventArgs) Handles btnSelect.Click
    Dim openFileDialog As OpenFileDialog = New OpenFileDialog()
    If openFileDialog.ShowDialog() = DialogResult.OK Then
        Dim xmlFilePath As String = openFileDialog.FileName
        Using ds As DataSet = New DataSet()
            dataGridView1.DataSource = ds.Tables(0)
        End Using
    End If
End Sub
Read, Parse and Import XML file in Windows DataGridView using C# and VB.Net