Outputting the last 6 digits using XSL
xml, xslt
Solution
The 2nd parameter to the `substring` function is the start position. You want to start taking characters from the `length-6` position.
Try
substring(@Text, string-length(@Text) - 6)
Problem
I am trying to come up with a way using XSL to output the last 6 digits of the following field ``` <NameReference Text="4380.401.0500-111820" /> ``` I wrote the following expression based on the xml file: ``` <xsl:if test=""> <xsl:for-each select="NameReference"> <ID> <Data> <xsl:value-of select="substring(@Text,-6)"/> </Data> </ID> </xsl:for-each> </xsl:if> ``` However, the output was as follows “43804010500111820”. It basically parses the entire field as the desired data, where i am only looking for the last 6 digits after the dash '-' . I was trying to go from left to right, but that hasn’t worked. Any help is much appreciated.