Bind XML file to DataSet and bind to asp datagrid
<%@ Import namespace="System.Data" %>
<html>
<head>
<title>Read XML file</title>
</head>
<body>
<H2>Read XML file</H2>
<asp:Label id="lblXMLFileName" runat="server" /><BR/><BR/>
<asp:DataGrid id="dgServers" runat="server" />
</body>
</html>
<script language="VB" runat="server">
Sub Page_Load(Source As Object, E As EventArgs)
Dim strXMLFile As String = MapPath("Multiple_levels.XML")
lblXMLFileName.Text = strXMLFile
Dim objDataSet As New DataSet()
objDataSet.ReadXml(strXMLFile)
dgServers.DataSource = objDataSet.Tables(0).DefaultView
dgServers.DataBind()
End Sub
</script>
<%--
<?xml version="1.0" standalone="yes"?>
<CarList>
<Car>
<ModelName>A</ModelName>
<Doors>2</Doors>
<ColorList>
<Color>Color 2</Color>
<Color>Color 3</Color>
<Color>Color 4</Color>
</ColorList>
</Car>
<Car>
<ModelName>Model 2</ModelName>
<Doors>3</Doors>
<ColorList>
<Color>Red</Color>
<Color>Yellow</Color>
<Color>Blue</Color>
</ColorList>
</Car>
</CarList>
--%>
Related examples in the same category