PC Review


Reply
Thread Tools Rate Thread

DetailsView with XmlDataSource (perhaps XPath issue?)

 
 
pompair
Guest
Posts: n/a
 
      27th Jan 2008
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:

<aspetailsView 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>
</aspetailsView>


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 <text> fields 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-
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlDataSource XPath question Jones Microsoft ASP .NET 1 1st Oct 2008 04:27 AM
C# - XPath, XMLDataSource and a DataGridView Darth Continent Microsoft C# .NET 5 6th Feb 2008 12:53 PM
C# - XPath for XMLDataSource? Darth Continent Microsoft C# .NET 3 4th Feb 2008 02:19 PM
XmlDataSource & XPATH & DataList =?Utf-8?B?cGVsZWdrMQ==?= Microsoft ASP .NET 1 24th Jul 2007 02:08 AM
Xpath with XMLDatasource Disccooker@gmail.com Microsoft ASP .NET 1 3rd Mar 2007 11:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.