Reputation: 163
I want to select a particular (3rd comma separate value) String that comma-separated in XSLT.
Input:
<table>
<tr>
<td>ABC, 2, 2, 4, 10</td>
</tr>
<tr>
<td>VSD, , 4, 3, 9</td>
</tr>
</tablr>
Outputshould be:
<root>
<num>4</num>
<num>3</num>
</root>
tried code:
<xsl:template match="td">
<root>
<num>
<xsl:value-of select="text()"/>
</num>
</root>
</xsl:template>
My tried code does not give the correct value. I am using XSLT 2.0
Upvotes: 1
Views: 136
Reputation: 56162
You need to use tokenize
function:
<xsl:variable name="fields" select="tokenize(text(), ',')" />
<xsl:value-of select="$fields[4]"/>
Upvotes: 2