I tried to substring data with single quote in XSLT:
String : DataFromXML:'12345'
expected Result: 12345
<xsl:value-of select="substring-after('$datafromxml','DataFromXML:')"/>
Result: '12345'
i tried below code
<xsl:value-of select="substring-after('$datafromxml','DataFromXML:'')"/> <xsl:value-of select="substring-after('$datafromxml','DataFromXML:'')"/> <xsl:value-of select="substring-after('$datafromxml','DataFromXML:'')"/>
Error:
String literal was not closed 'DataFromXML:'--->'<---
substring-after() Function — Returns the substring of the first argument after the first occurrence of the second argument in the first argument. If the second argument does not occur in the first argument, the substring-after() function returns an empty string.
XSLT replace is deterministic and does string manipulation that replaces a sequence of characters defined inside a string that matches an expression. In simple terms, it does string substitution in the specified place by replacing any substrings. Fn: replace function is not available in XSLT1.
XSLT <xsl:text> The <xsl:text> element is used to write literal text to the output. Tip: This element may contain literal text, entity references, and #PCDATA.
The general rules for escaping are:
In 1.0:
"
or '
In 2.0:
"
or '
The use of a variable $quot or $apos as shown by Vitaliy can make the code much clearer.
This should work:
<xsl:variable name="apos">'</xsl:variable> ... <xsl:value-of select="substring-before(substring-after($datafromxml, concat('DataFromXML:', $apos)), $apos)" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With