How to get only numbers from string in XSLT
To get only numeric value from input string we can use translate function in XSLT.
<ns0:result>
<xsl:value-of select="translate (/ns0:process/ns0:input, translate (/ns0:process/ns0:input, '0123456789', '' ), '')"/>
</ns0:result>
/ns0:process/ns0:input is having string from which numeric value should be get.
nested translate function will work as below.
- Inner translate(). This produces all characters of the string, except digits.
- Outer translate(). This deletes from the string all characters produced by the inner translate(). What remains is just the wanted characters (the digits).
Comments
Post a Comment