• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1419
  • Last Modified:

XmlDataSource XPath Query Help

I have an ASP.NET web form page on which I'm going to use repeater controls along with an xmlDataSource to display an archived listing of blog entries. I'm used to using databases and not working with XML so I'm not completely familiar with the XPath syntax. The xml file looks like this (minus the prefixed periods):

<BlogEntries>
..<BlogEntry @date="7/23/07 10:00 AM" @poster="John Doe" @title="This is a blog post" @id="123456">
....<![CDATA[<p>This is also a test post.</p>]]>
..</BlogEntry>
..<BlogEntry @date="5/10/07 3:00 PM" @poster="John Doe" @title="Test Post" @id="12345">
....<![CDATA[<p>This is a test post.</p>]]>
..</BlogEntry>

What I want to do is to have my page look something like this:

July 2007
- This is a blog post. (Posted by John Doe on 7/23/07 @ 10:00 AM)
May 2007
- Test Post (Posted by John Doe on 5/10/07 @ 3:00 PM)

I've tried using an XPath filter on the xml data source like such:
BlogEntries/BlogEntry[distinct-values(year-from-duration(@date))] just to get started and other various ways from looking at documenation online but I always either get no results or I get error messages about user defined functions like it doesn't recognize distinct-values() or year-from-duration().

How can I go about getting to what I want? Also, does asp.net's XML Data source only support minimal functionality of XPath queries or was I just using distinct-values and other XPath functions incorrectly?
0
TSmooth
Asked:
TSmooth
1 Solution
 
jkmyoungCommented:
I think the problem is you're trying to use XPATH 2.0 functions (distinct(), year-from-duration()), when ASP generally only recognizes XPATH 1.0

I suggest trying a simpler xpath 1.0 expression first: eg
BlogEntries/BlogEntry[@date]
and sort on the date.

Here's a list of XPATH 1.0 functions:
http://www.mulberrytech.com/quickref/XSLT_1quickref-v2.pdf 
0
 
TSmoothAuthor Commented:
Thanks for your reply, I'm going to have to come up with another plan to do what I wanted.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now