Filter RSS feed articles

Questions about XML that are not covered by the other forums should go here.
dvonjr
Posts: 3
Joined: Fri Sep 28, 2007 1:43 am

Filter RSS feed articles

Post by dvonjr »

Ok, this may become confusing because I don't really understand what I'm
doing, but here goes.

I what to add some news from a related site that uses RSS to push news. The
feed actually has 16 records/articles, (two months worth). The space I can
put this in on my site can accomidate about 5 or 6 records/articles. I've
got the feed set up on a test page and see all 16 records. When I use the
Data View Preview to limit the number of records to 5, the test page shows
only 5 records, however when I insert the test page (as an include) into the
area of my site where it will disply the news it defaults to all 16 records.

The news feed produces about 5 articles a month, so is there a way to filter
out articles older than the current month?

Some one else told me that I might be able to use XPATH to do this but I don't know anything about this so some help would be appreciated.
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post by jkmyoung »

You could always copy just the nodes from the first 5 articles, using XSLT and xpath
If you want date filtering, you'd need a node in the rss feed that specifies when each article has been published.

If you could post part of the feed, or the link to it, it'd be easier to create a custom XSLT for you.
dvonjr
Posts: 3
Joined: Fri Sep 28, 2007 1:43 am

Post by dvonjr »

jkmyoung wrote:You could always copy just the nodes from the first 5 articles, using XSLT and xpath
If you want date filtering, you'd need a node in the rss feed that specifies when each article has been published.

If you could post part of the feed, or the link to it, it'd be easier to create a custom XSLT for you.
Thanks for your reply and for your help. The link is http://community.kiwanisone.org/blogs/k ... s/rss.aspx
So if using the current date, all articles older than say 35 day's would not be posted. Hopefully that way the displayed feed would not grow larger than 5 or 6 articles.

I found a free tool online to do this at RSS Feed Reader however, free is not really free when you have to deal with Adware. Plus, if their server goes offline - no feed.
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Post by jkmyoung »

You could actually use their own XSLT at http://community.kiwanisone.org/utility ... ts/rss.xsl

Just make modifications to add filters. You can also remove their header text if you want. Assuming there is only one channel, the line to change is here:
<xsl:for-each select="rss/channel/item">

For the first 5, change it to:
<xsl:for-each select="rss/channel/item[position() < 6]">

If you want to actually filter on date, you'd use the pubdate element, eg:
<pubDate>Thu, 23 Aug 2007 20:50:00 GMT</pubDate>
To be honest, doing it this way is a lot harder since the date uses Strings instead of numbers for the month, further, you would have to pass in the current date as a parameter into the xslt, more complications.
dvonjr
Posts: 3
Joined: Fri Sep 28, 2007 1:43 am

Post by dvonjr »

Thanks I'll check this out.
Post Reply