To use a counter in a XSL For-Each block, you can use the position() function, the Counter starts at value 1.

Sample XSL

<xsl:for-each select="Order/Products/Product">
    <position><xsl:value-of select="position()"></xsl:value-of></position>
</xsl:for-each>

see also MSDN position Function

Leave a Reply