Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to bind a nested xml file to repeater control?

Posted on 2011-03-19
2
Medium Priority
?
878 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

704 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