Problem sorting RSS feed by date using XSL
Posted
by Buckers
on Stack Overflow
See other posts from Stack Overflow
or by Buckers
Published on 2009-02-16T22:50:58Z
Indexed on
2010/05/08
19:08 UTC
Read the original article
Hit count: 526
I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time.
The date fields in the RSS feed are in the following format: "Mon, 16 Feb 2009 16:02:44 GMT"
I'm having big problems getting the records to sort correctly - I've tried lots of different code examples I've seen, but none seem to sort the records correctly. The code for my XSL sheet is shown below, and the feed in question is here.
Very grateful for anyones help!!!
Thanks,
Chris.
XSL CODE:
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:digg="http://digg.com//docs/diggrss/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:template match="/">
<xsl:for-each select="//*[local-name()='item'][position() < 6]">
<p>
<a>
<xsl:attribute name="href">
<xsl:value-of select="*[local-name()='link']"/></xsl:attribute>
<xsl:attribute name="target">
<xsl:text>top</xsl:text>
</xsl:attribute>
<xsl:value-of select="*[local-name()='title']"/>
</a>
<br/>
<span class="smaller"><xsl:value-of select="*[local-name()='pubDate']" disable-output-escaping="yes"/></span>
</p>
</xsl:for-each>
© Stack Overflow or respective owner