Solved

How to bind a nested xml file to repeater control?

Posted on 2011-03-19
2
868 Views
Last Modified: 2012-05-11
Hello experts,

I have had some expert help with binding a flat xml file.  Now I need to bind a nested xml file to a repeater (in my case two repeaters, one indide the other).  I have attached the file and my current code which works in that it displays the teams, the team id (ident) and team homes but does not display the members.

My display looks like:

QU
3
QATAR

VCU
1
Vancouver

MUN
2
Memorial

CNAQ
0
Newfoundland

I need the team members to display.  I have read a lot on the net about this but I cannot, no matter what I try, get this to work.

Please save me.

Interestingly, if I delete the home and positions nnodes, I can display the team members.  I don't, however, have any control over the structure of the xml file.

Thanks

Vince
<asp:Repeater ID="Repeater" runat="server" DataSourceID="XmlDataSource">
         <ItemTemplate>
              <strong><%# XPath("@name") %><br /></strong>
              
              <%#XPath("@ident")%><br />
              <%#XPath("home")%><br /><br />
              <asp:Repeater ID="Repeater2" runat="server" DataSource='<%# XPathSelect("round/team/home/positions/member") %>'>                   
              <ItemTemplate>
              Speaker: <asp:Label ID="LabelSpeaker" runat="server" Text='<%# XPath("@name") %>' />
                             
              </ItemTemplate>                    
              <SeparatorTemplate><br /></SeparatorTemplate>                
              </asp:Repeater>
            </ItemTemplate>
        </asp:Repeater>
        <asp:XmlDataSource ID="XmlDataSource" runat="server" DataFile="~/Data/teams1-main.xml" >
        </asp:XmlDataSource>

Open in new window

<?xml version='1.0' encoding='utf-8'?>
<round name="main" parent="main" knockout="no">
  <team name="QU" ident="3" pullups="0">
    <home>QATAR</home>
    <positions></positions>
    <member name="Queenie">
      <points>0</points>
      <rounds>0</rounds>
    </member>
    <member name="Queller">
      <points>0</points>
      <rounds>0</rounds>
    </member>
  </team>
  <team name="VCU" ident="1" pullups="0">
    <home>Vancouver</home>
    <positions></positions>
    <member name="Victor">
      <points>0</points>
      <rounds>0</rounds>
    </member>
    <member name="Victoria">
      <points>0</points>
      <rounds>0</rounds>
    </member>
  </team>
  <team name="MUN" ident="2" pullups="0">
    <home>Memorial</home>
    <positions></positions>
    <member name="Mandy">
      <points>0</points>
      <rounds>0</rounds>
    </member>
    <member name="Mary">
      <points>0</points>
      <rounds>0</rounds>
    </member>
  </team>
  <team name="CNAQ" ident="0" pullups="0">
    <home>Newfoundland</home>
    <positions></positions>
    <member name="Feras">
      <points>0</points>
      <rounds>0</rounds>
    </member>
    <member name="Mohd">
      <points>0</points>
      <rounds>0</rounds>
    </member>
  </team>
</round>

Open in new window

0
Comment
Question by:vstack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35179051
The following:
XPathSelect("round/team/home/positions/member")

Open in new window

Should say:
 XPathSelect("member")

Open in new window

As you are binding the nested repeater to a child node of the "team" node, you need to specify the XPath relative to the context node.
0
 

Author Closing Comment

by:vstack
ID: 35908583
Ok.  It's tken me some time to figure out nested xml files.  Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question