Pulling Child Element from XML into ASP.NET Repeater

liunx

Guest
I'm simply trying to pull all of my data from a basic XML doc into an ASP.NET web form, but I've had no luck. I'm able to pull the regular element data just fine, but any attemps to pull child elements into a DataGrid, DataList or Repeater result in this error message:
Server Error in '/' Application.
CHILDELEMENTNAME is neither a DataColumn nor a DataRelation for table deptinfo.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: CHILDELEMENTNAME is neither a DataColumn nor a DataRelation for table deptinfo.

Isn't there a simple way to call this data into one of the built-in ASP.NET web controls? Any & all help is appreciated, as I'm about to pull all of my hair out.

P.S. Here's the code for the pages I'm working with:

XML doc
<?xml version="1.0" encoding="UTF-8"?>
<deptinfo>
<contactinfo>
<address>...</address>
<city>...</city>
<zip>...</zip>
</contactinfo>
<hours>
<days>...</days>
<times>...</times>
</hours>
<description>...</description>
</deptinfo>

ASP.NET Web Form (Repeater)
<%@ Page Language="VB" Debug="true" EnableSessionState="false" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
Sub Page_Load
If Not Page.IsPostBack then
Dim xmlAD = New DataSet
xmlAD.ReadXml("http://FILENAME.xml")
aspxAD.DataSource = xmlAD
aspxAD.DataBind()
End If
End Sub

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

<HeaderTemplate>
##header##
</HeaderTemplate>

<ItemTemplate>
<div>Address: <%#Container.DataItem("address")%></div>
<div>City: <%#Container.DataItem("city")%></div>
<div>Zip: <%#Container.DataItem("zip")%></div>
<div>Description: <%#Container.DataItem("description")%></div> <!--THIS IS THE PROBLEM-->
<div>Days of the week: <%#Container.DataItem("days")%></div> <!--THIS IS THE PROBLEM-->
</ItemTemplate>

<FooterTemplate>
##footer##
</FooterTemplate>

</asp:Repeater>
</form>
</body>
</html>
 
Back
Top