Jump to content

for-each Trouble - Please Help!


Guest losvatic

Recommended Posts

Guest losvatic

Hello all,I new to XML/XSL and I need help please, I need to get the 5 latest press release from a XML feed that has about 20 in it. I thought this would be easy but I guess I was wrong. :) Here's what I've gotten so far:<xsl:for-each select="rss/channel/item"> <table width="500" border="0" cellpadding="3" cellspacing="0" class="table-bodycopy"> <tr> <td><a href="{link}" target="_blank" class="arialfont18"><xsl:value-of select="title"/></a></td> </tr> <tr> <td><xsl:value-of select="description"/></td> </tr> <tr> <td><xsl:value-of select="pubDate"/></td> </tr> <tr> <td> </td> </tr> <tr> <td><xsl:number level="any" count="title" format="0"/></td> </tr> </table> <br /></xsl:for-each>If someone could please tell me how to limit the number of items and/or time the for-each repeates through the nodes, I would be greatful.Thanks,Len

Link to comment
Share on other sites

...and to be more precise, use a predicate. Something like this:

<xsl:for-each select="rss/channel/item[position() <= 5">

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...