Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Function to limit nodes? (using xslt to format xml from rss feed) >Thread Next - Re: Function to limit nodes? (using xslt to format xml from rss fe Re: Function to limit nodes? (using xslt to format xml from rss feed)To: NULL Date: 5/18/2008 11:40:00 AM <robinchesterman@g...> wrote in message news:1970fd18-006d-499a-8597-4c94fb558d82@j...... > I've just started using xslt, and it seems straightforward enough (for > now!). I am using a simple xsl template to format and display news > items from an rss news feed: > > <xsl:template match="rss"> > <xsl:apply-templates select="channel"/> > </xsl:template> > > <xsl:template match="channel"> > <xsl:apply-templates select="item"/> > </xsl:template> > > <xsl:template match="item"> > <dt> > <a href="/"><xsl:value-of select="title"/></a> > </dt> > <dd> > <ul> > <li> > <a><xsl:attribute name="href"><xsl:value-of > select="link"/></xsl:attribute> > <xsl:value-of select="description"/> > </a> > </li> > </ul> > </dd> > </xsl:template> > > > However, in another section of the site I'm building, I would like to > display only the four or so most recent items of the rss feed, rather > than the whole lot. > > Can anyone tell me how to do this using xslt functions? As you will > see, at the moment my knowledge is limited to applying a blanket > template to every item. > > Any help would be very much appreciated. > > Many thanks, > > Robin Use the position() function in the item template: <xsl:template match="item"> <xsl:if test="position() < 5"> </xsl:if> </xsl:template> -- Joe Fawcett (MVP - XML) http://joe.fawcett.name | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
