Sign in to follow this  
johnnyBravo

[web] XSL, 'for each' looping a variable, how to get values out (instead of just 1st )

Recommended Posts

the variable 'countryorganizations' has many 'organizations' in it. I want to loop through the variable and output the 'name' attribute from each 'countryorganization' like shown below.
<xsl:variable name="countryorganizations" select="$orgs/organization[@hqcountry = $countryname]"></xsl:variable> 
<xsl:for-each select="$countryorganizations">
   <xsl:value-of select="$countryorganizations/@name"/>
</xsl:for-each>



Currently the code only displays the first element's name over and over. How can I get out the other names out? thx edit: I just changed the value of select to "./@name" And it 'seems' to be working, not sure what this dot means though.

Share this post


Link to post
Share on other sites
I think it's <xsl:value-of select="@name"/> and not <xsl:value-of select="$countryorganizations/@name"/>

BTW, why the variable? This should work as well:


<xsl:for-each select="$orgs/organization[@hqcountry = $countryname]">
<xsl:value-of select="@name"/>
</xsl:for-each>

Share this post


Link to post
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

Sign in to follow this