• Advertisement
Sign in to follow this  

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

This topic is 3889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement