DataSet read XML data and bind to asp datagrid
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim objDataSet As New DataSet()
objDataSet.ReadXml(Server.MapPath("NewEmployees.xml"))
dgEmployees.DataSource = objDataSet.Tables(0).DefaultView
dgEmployees.DataBind()
End Sub
</script>
<html>
<body>
<asp:DataGrid id="dgEmployees" runat="server" />
</body>
</html>
<%--NewEmployees.xml
<?xml version='1.0'?>
<employees>
<employee id="1">
<firstName>Nancy</firstName>
<lastName>Lee</lastName>
<city>Seattle</city>
<state>WA</state>
<zipCode>98122</zipCode>
</employee>
<employee id="2">
<firstName>Jason</firstName>
<lastName>Wang</lastName>
<city>Vancouver</city>
<state>WA</state>
<zipCode>98123</zipCode>
</employee>
</employees>
--%>
Related examples in the same category