Hi everybody! I'm trying to figure out a good way of getting the position of the third-last node. I'm using a for-each to create a navigation menu and I really want change attributes of the last, second-last and third-last node.
I've made some efforts using preceding-sibling:: but I'm still a bit new to all this and can't manage to completing my code.
Thank you for taking a look at my problem and hopefully you can help me out!
Get position of the third-last node, 4.5
Hi everybody!
I'm trying to figure out a good way of getting the position of the third-last node. I'm using a for-each to create a navigation menu and I really want change attributes of the last, second-last and third-last node.
I've made some efforts using preceding-sibling:: but I'm still a bit new to all this and can't manage to completing my code.
Thank you for taking a look at my problem and hopefully you can help me out!
Cheers /Max
Hi Max,
Here's one way to get it - depends a little on what you're trying to achieve, but this will work inside the for-each:
<xsl:if test="position() = last() - 2"> <!-- do stuff --> </xsl:if>
/Chriztian
Hi Max,
You can use the XLST functions count() and position() to achieve this.
Thank you so much, both of you!
is working on a reply...