4 users online. Create an account or sign in to join them.Users
"For Each" Question
This is an open discussion with 3 replies, filed under General.
Search
Try the <xsl:attribute /> element.
<li>
<xsl:attribute name="class">
<xsl:for-each select="category/item">
<xsl:value-of select="." /><xsl:text> </xsl:text>
</xsl:for-each>
</xsl:attribute>
</li>
And to avoid the space after the last class :-)
<li>
<xsl:attribute name="class">
<xsl:for-each select="category/item">
<xsl:value-of select="." />
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:attribute>
</li>
Brilliant! Cheers guys, works perfectly!
Create an account or sign in to comment.
I’m making a portfolio, and each item is displayed in a list. I have the following XSL at the moment:
<li class="{../catagory/item}">This outputs a category in the class name, which works perfect. However, I want to be able to select 2 or more categories, so the HTML output would be this:
My XML is this:
What would be the best way to achieve this? Thanks!