0

I have a string like this and i need to get specific substring between specific |'s. Like between first | and second | (5000935). I use the code below for that but i need easier way for further substrings.

102237315|5000935|771803||139566.66|0|139566.66|139566.66|||string|Y||P150007170|46193808

<td><xsl:value-of select="substring-before(substring-after( . ,'|'),'|')"/></td>
Meruem81
  • 1
  • 1

1 Answers1

0

If you're able to use XSLT 2.0 you can tokenize on each pipe

your XML:

<td><string>102237315|5000935|771803||139566.66|0|139566.66|139566.66|||string|Y||P150007170|46193808</string></td>

XSL:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:template match="/">
    <output>
      <xsl:variable name="token" select="tokenize(td/string, '\|')" />
      <xsl:value-of select="$token[3]"/>
    </output>
  </xsl:template>
  
</xsl:stylesheet>

Outputs:

<output>771803</output>

note the | delimiter will need to be escaped with a \ as seen above.

Will Webb
  • 795
  • 6
  • 20