XmlDataSource XPath Query Help

Posted on 2007-07-23
Last Modified: 2013-11-18
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):

..<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 @date="5/10/07 3:00 PM" @poster="John Doe" @title="Test Post" @id="12345">
....<![CDATA[<p>This is a test post.</p>]]>

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's XML Data source only support minimal functionality of XPath queries or was I just using distinct-values and other XPath functions incorrectly?
Question by:TSmooth
    LVL 12

    Accepted Solution

    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
    and sort on the date.

    Here's a list of XPATH 1.0 functions:
    LVL 16

    Author Comment

    Thanks for your reply, I'm going to have to come up with another plan to do what I wanted.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now