|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm trying to get a total count of an XML element. (return the number of total tags) i used count()
Code:
<xsl:for-each select="collection/artist"> <xsl:value-of select="count(album)"/> </xsl:for-each> but it returns them idividualy and not as a sum like i would like it to. Here's what it returns 86151882411 (should be 8, 6, 1, 5, 1.....) This is the number of album tags for each album. I want it to return the sum which is 45. How should I do this? |
|
#2
|
|||
|
|||
|
How about...
Code:
<xsl:value-of select="count(collection/artist/album)" /> |
|
#3
|
|||
|
|||
|
In the code you posted you used the loop for each artist, it should return the value of each album, so you can simply avoid the loop and use the full path as nBIL stated or for total albums in each collection you shall reduce the for each path to select="collection" and value of "artist/album"
also to get a comma after each number, add a comma after the value-of statement p.s in a more complicated situations you can use variables |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > count() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|