Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

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

This topic is 4066 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!