473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Xpath with XMLDatasource

i am trying to use XPath and the XMLDataSource to display data from an
XMLDocument and am getting nowhere. What i would like to do is have a
repeater display a label for Seed, label for Team Name and a Text Box
for each game - like an NCAA bracket.

1. Team1 [__]
16. Bradley [__]

8. Missouri [__]
9. USM [__]

and so on.

I have created an XMLDataSource like so:

<asp:XmlDataSource OnDataBinding="XmlDataSource1_DataBind"
ID="XmlDataSource1" runat="server" DataFile="/ncaa/App_Data/
Round1.xml" XPath="Head2Head/Round[@Id='First']/Bracket[@Id='A']">
</asp:XmlDataSource>

and a repeater like so:
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="XmlDataSource1">
<ItemTemplate>
<%# XPath("@Seed") %>. <%# XPath("@Name") %<asp:TextBox
Width="32" runat="server" ID="txtWager"></asp:TextBox><br />
</ItemTemplate>
<SeparatorTemplate>
-----------------------------<br />
</SeparatorTemplate>
</asp:Repeater>
here is my xml:
<Head2Head xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Head2Head.xsd">
<Round Id="First">
<Bracket Id="A">
<Game Pgm="P01">
<Team Rnr="1" Name="Team 1" Odds="9-1" Seed="1"/>
<Team Rnr="2" Name="Team 16" Odds="2-1" Seed="16"/>
</Game>
<Game Pgm="P02">
<Team Rnr="1" Name="Team 8" Odds="9-1" Seed="8"/>
<Team Rnr="2" Name="Team 9" Odds="2-1" Seed="9"/>
</Game>
</Bracket>
</Round>
</Head2Head>

so, what am i doing wrong? i tried creating two datasources, and two
repeaters, still nothin.

Mar 2 '07 #1
1 3161
Your XPath Query is incorrect
1)Your XPath should be like this:
XPath="Head2Head/Round[@Id='First']/Bracket[@Id='A']/Game"
So your XmlDataSource will be like this
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/Round1.xml"

XPath="Head2Head/Round[@Id='First']/Bracket[@Id='A']/Game"></asp:XmlDataSource>

2)Your XPath binding expression in the repeater should be like this as you
wish to display an attribute value
<%# XPath("Team/@Seed")%>
Your final repeater code should be similar to this
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1">
<ItemTemplate>
<%# XPath("Team/@Seed")%>
Mar 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: trond | last post by:
Hello all, I am building a personal web site in VS2005 as a kind of learing project for myself, so forgive me if this is a novice question. I am planning to use an XML file called...
0
by: Thor W Hammer | last post by:
Is it possible to use dynamic xpath expressions with the <%#XPath("..")%> syntax and XmlDataSource? This is a couple of examples to illustrate what I think about: 1: <%#XPath("*")%> 2:...
0
by: Kurt Kubein | last post by:
Hi, I have this xmldoc linked to a xmldatasource in .Net 2.0 <MENUROOT title="Home" visible="true"> <MENU title="subnode_1" visible="true"> <MENUITEM title="leafnode_1" visible="true" />...
2
by: dba123 | last post by:
I have an issue where I want to put an image right before the text for each record below in a GridView. The problem is, the XPath is rss/channel/item". So since I have the picture in my XML file...
3
by: Opa | last post by:
Hi, I have and XMLDataSource which I am using in a GridView control and am customizing the grid with <ItemTemplate>. My XML datasource has an element with an attribute called "private". I want...
1
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
if for example i have an xml with 10 childnodes and i want by random to get 1 of them how do i do that? my current code that work with is : <asp:XmlDataSource ID="XmlDataSource1" runat="server"...
2
by: pidakar | last post by:
hello! following is xml file: '===================== <Root> <groups id="1"> <author id="1">author 11</author> <author id="2">author 12</author> <author id="3">author...
2
by: shiznit | last post by:
In ASP i used XMLDataSource to create a small menu. For the following xml how would i get just the @nav value and create a small navigation menu like this: Menu architecture: exhibition...
0
by: pompair | last post by:
Hello, I'm making a quiz game for fun. I have an xml file like this: <?xml version="1.0" encoding="utf-8" ?> <results> <index>99</index> <answers>11</answers> <questions> <question id="1">
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.