Forum Moderators: open

Message Too Old, No Replies

Select Top 10

Xsl

         

gosman

12:44 am on Dec 12, 2007 (gmt 0)

10+ Year Member



Is it possible to use XSL to select only the first 10 results from an XML source?

cmarshall

2:51 am on Dec 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Absolutely. As in all XSLT, there's no easy "for(i=0;..." construct, you need to set up a "<xsl:for-each" to do it.

Something like this:

<xsl:for-each select="aaa/bbb">
<xsl:if test="position < 10">
.
.
.
</xsl:if>
</xsl:for-each>

gosman

1:23 pm on Dec 12, 2007 (gmt 0)

10+ Year Member



Thanks cmarshall.

Worked a treat

<xsl:if test="position() &lt; 10">

Regards

Gosman

cmarshall

1:48 pm on Dec 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, I always forget the "&lt;", and <oXygen/> yells at me.