473,770 Members | 3,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:DetailsVie w ID="DetailsView 1" runat="server"
AllowPaging="Tr ue" AutoGenerateRow s="False"
DataSourceID="d s1" DataKeyNames="i d">
<Fields>
<asp:BoundFie ld DataField="id" HeaderText="id"
SortExpression= "id" />
<asp:BoundFie ld DataField="text " HeaderText="tex t"
SortExpression= "text" />
</Fields>
</asp:DetailsView >
I have XmlDataSource setup like this:
<asp:XmlDataSou rce ID="ds1" runat="server" DataFile="~/
XMLFile1.xml" XPath="//results/questions/question">
</asp:XmlDataSour ce>

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 1763

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

Similar topics

2
3168
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 at i_am_the_freshmaka@hotmail.com
0
1010
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 expression. My XML file doesn’t have a schema (it’s a flat file no schema really needed) and it has no namespace. What do I do!?
0
1482
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: <%#XPath("*%>]")%>
3
9170
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 really had any success. I'm pretty sure I should be casting my XPathSelect() call to something so I can get at its attributes. This seems like it should be easy, and maybe I'm missing something obvious. Does anyone have any ideas? Here is the...
0
1359
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" description="Home" url="~/default.aspx"> <siteMapNode title="Buy" description="Buy stuff" url="~/Buy.aspx" /> <siteMapNode title="Sell" description="Sell stuff"
1
3174
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 and a Text Box for each game - like an NCAA bracket. 1. Team1 16. Bradley 8. Missouri 9. USM
2
1844
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 property url in the xml which is there Any ideas? ** XML datasource file below
8
2071
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 string sXML = GetXmlFromWebService(Request); XmlDataSource ds = new XmlDataSource(); ds.Data = sXML;
1
1813
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 machine everything runs fine and the latest data is downloaded and displayed correctly. On the remote server this was also running fine but since a few days ago the controls will only show old data even though I know the feeds have been updated. The...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8891
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.