Hi tareq16278,
Please refer below sample.
XML
<?xml version="1.0" encoding="utf-8" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/1999/xhtml">
<url>
<loc>https://www.1.com/railway/bangladesh/train/1/subarna-express</loc>
<lastmod>2022-11-18</lastmod>
</url>
</urlset>
HTML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="loc" HeaderText="Location" />
<asp:BoundField DataField="lastmod" HeaderText="Last Modified" />
</Columns>
</asp:GridView>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGridView();
}
}
private void BindGridView()
{
using (DataSet ds = new DataSet())
{
ds.ReadXml(Server.MapPath("~/XMLFile.xml"));
GridView1.DataSource = ds.Tables["url"];
GridView1.DataBind();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindGridView()
End If
End Sub
Private Sub BindGridView()
Using ds As DataSet = New DataSet()
ds.ReadXml(Server.MapPath("~/XMLFile.xml"))
GridView1.DataSource = ds.Tables("url")
GridView1.DataBind()
End Using
End Sub
Screenshot