Link to home
Start Free TrialLog in
Avatar of Paulconsulting
Paulconsulting

asked on

Limit number of Rows returned in XSLT Loop

I'm using XSLT to style the data in an RSS Feed and I want to limit the number of rows returned:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xmlns:atom10="http://www.w3.org/2005/Atom">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="/">
<img src="{rss/channel/image/url}" />
<br />
<xsl:for-each select="rss/channel/item">
  <a href="{rss/channel/item/feedburner:origLink}"><xsl:value-of select="title"/></a> <br />
  <xsl:value-of select="description" disable-output-escaping="yes"/>
</xsl:for-each>
 
</xsl:template>
</xsl:stylesheet>

Open in new window

Avatar of zc2
zc2
Flag of United States of America image

try to use the position() function like in follows:

select="rss/channel/item[position()<4]"
I'm sorry, the experts-exchange's text editor replaced a '& lt;' with a '<',
see the code snippet below, hope it will remain as is

select="rss/channel/item[position()&lt;4]"

Open in new window

Avatar of Paulconsulting
Paulconsulting

ASKER

That kinda works, but <4 just returns 2 results - I have to do <7 to return 5 rows :~
ASKER CERTIFIED SOLUTION
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your right, I missed one of the rows
Thanks :)