Nodesets Length

In XLST, how would you know the length of a node-set?

+7
xml xslt nodesets
source share
3 answers
<xsl:variable name="length" select="count(nodeset)"/> 
+9
source share

no need to embed this in

 <xsl:variable name="length" select="count(nodes/node)"/> 

though ... you can just print it like this:

 <xsl:value-of select="count(nodes/node)"/> 

or use it in an if statement:

 <xsl:if test="count(comments/comment) > '0'"> <ul> <xsl:apply-templates select="comments/comment"/> </ul> </xsl:if> 
+8
source share

In XSLT, things are generally not referred to as Arrays , as this does not happen in XSLT. Technical term: nodesets (consisting of zero or more nodes) or in XSLT 2.0 sequences .

+2
source share

All Articles