How to Call XML Child Element From ASP.NET

admin

Administrator
Staff member
I hope that there's a simple answer to this question. How do I go about calling an XML child element from an ASP.NET form?

When I try to pull XML data into an ASP.NET DataGrid, I only see the main elements' data. None of the child elements show up. For instance, if I have an XML file like this:

<root>
<element>
<sub_element>
</sub_element>
</element>
</root>

...and I then try to pull that data like this:

<%@ import Namespace="System.Data" %>
<script runat="server">

Sub Page_Load
If Not Page.IsPostBack then
Dim xmlAL = New DataSet
xmlAL.ReadXml("http://FILENAME.xml")
aspxAD.DataSource = xmlAL
aspxAD.DataBind()
End If
End Sub

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PAGETITLE</title>
</head>
<body>
<form runat="server">
<asp:DataGrid id="aspxAD" runat="server"></asp:DataGrid>
</form>
</body>
</html>

...only the <root> and <element> elements show up. Am I missing something?
 
Back
Top