I have value coming as
<sf:pitch><p><span style="color: rgb(68, 68, 68);">https://PPsdfgndgnlksdnflksklenrgkdngldsfklsndfg.com.au</span></p> </sf:pitch>
and I want the output to be like and remove every "p", "span" and non text stripped from the SF:pitch value.
https://PPsdfgndgnlksdnflksklenrgkdngldsfklsndfg.com.au
I have put the code to remove <p>
but I want a generic code to remove any tag from the value.
Code which I used to remove <p>
is
<xsl:value-of select="substring-before(substring-after(*:Envelope/*:Body/*:retrieveResponse/*:result/*:pitch, '<p>'), '</p>')" disable-output-escaping="yes"/>
CodePudding user response:
You say:
I want a generic code to remove any tag from the value
But there aren't any "tags" in the value of sf:pitch
; it's all a single string containing some escaped markup. Unless you convert the string to XML first (using either XSLT 3.0 or a separate transformation that disables the escaping) and process it as such, you must process it using string manipulation - which is difficult and error-prone.
Perhaps you could do something like:
<xsl:value-of select="replace($string, '.*>([^<] )<.*', '$1')" />
where $string
is the sf:pitch
element in your example.
But overall, this is not a good approach - see here why.
CodePudding user response:
<xsl:template match="sf:pitch">
<xsl:value-of select="text()"/>
</xsl:template>
But you have not stated whether it is every sf:pitch or any other possible variations.