<%@ 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 = Server.MapPath("Data.xml")
lblXMLFileName.Text = strXMLFile
Dim objDataSet As New DataSet()
objDataSet.ReadXml(strXMLFile)
dgServers.DataSource = objDataSet.Tables(0).DefaultView
dgServers.DataBind()
End Sub
</script>
File: ~\Data.xml
<?xml version="1.0" standalone="yes"?>
<CarList>
<Car>
<ModelName>A</ModelName>
<Doors>2</Doors>
<ColorList>
<Color>A</Color>
<Color>B</Color>
<Color>C</Color>
</ColorList>
</Car>
<Car>
<ModelName>B</ModelName>
<Doors>3</Doors>
<ColorList>
<Color>D</Color>
<Color>E</Color>
<Color>F</Color>
</ColorList>
</Car>
</CarList>
|