473,387 Members | 1,621 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,387 software developers and data experts.

DetailsView with XmlDataSource (perhaps XPath issue?)

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">
<spindex>1</spindex>
<text>question1</text>
</question>
<question id="2">
<spindex>2</spindex>
<text>question2</text>
</question>
... etc ...
</questions>
</results>
Then I have DetailsView setup like this:

<asp:DetailsView ID="DetailsView1" runat="server"
AllowPaging="True" AutoGenerateRows="False"
DataSourceID="ds1" DataKeyNames="id">
<Fields>
<asp:BoundField DataField="id" HeaderText="id"
SortExpression="id" />
<asp:BoundField DataField="text" HeaderText="text"
SortExpression="text" />
</Fields>
</asp:DetailsView>
I have XmlDataSource setup like this:
<asp:XmlDataSource ID="ds1" runat="server" DataFile="~/
XMLFile1.xml" XPath="//results/questions/question">
</asp:XmlDataSource>

Running the webform causes error: "A field or property with the name
'text' was not found on the selected data source".

The app works if I move the <textfields from elements to attributes!
Like this:

<?xml version="1.0" encoding="utf-8" ?>
<results>
<index>99</index>
<answers>11</answers>
<questions>
<question id="1" text="q2">
<spindex>1</spindex>
</question>
<question id="2" text="q2">
<spindex>2</spindex>
</question>
... etc....
</questions>
</results>

So I guess it's a XPath problem in my XmlDataSource's XPath setting.
How to make this work with the original xml file (with the <text>
fields as elementst)??

-pom-
Jan 27 '08 #1
0 1740

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

Similar topics

2
by: mike | last post by:
can somebody please show me some code that will let me populate a checkboxlist from the xmldatasource, and have the text property set to the names in the xml file thanks you can also email me...
0
by: Sean | last post by:
Case: Populate a DetailsView with an XML file. XMLDataSource control doesn’t ask for a schema. Just the XML, a transform file (xsl) if applicable (which its not in my case), and one Xpath...
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:...
3
by: Brian | last post by:
Using external XML, I'm trying to build a quiz, but I can't seem to specify the DataSource for the RadioButtonList within a Repeater ItemTemplate. I've tried a number of approaches, but I haven't...
0
by: Jon Davis | last post by:
My repeater is not repeating any items. I am trying to use an XmlDataSource to load a custom .sitemap file having content similar to as follows: <siteMap> <siteMapNode title="Home"...
1
by: Disccooker | last post by:
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...
2
by: rote | last post by:
I have a code below i'm trying to test It had a DataSetDatasource but i thinks its deprecated if yes what can i use in this scenario below? I used XmlDatasource but its saying it can't find the...
8
by: Wessel Troost | last post by:
We are using an XML data source in the Page_Load event of an ASP.NET page, like: protected void Page_Load(object sender, EventArgs e) { // Retrieve XML from web service for product idea in URL...
1
by: Sean | last post by:
I am experiencing a strange problem using the XMLDataSource and DataList controls which I cannot seem to resolve. I am using the controls to read and display a variety of RSS feeds. On my local...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.