How to replace text defined in a given tag or element using xslt, xslt string replace

Please help me with this xslt conversion.

Xml source

<xml> <test>This is a <bold>sample</bold> description. Please help me with a sample</text> </xml> 

Expected Result: This is a description of the sample . Please help me with a sample

I just need to make only the specified text in bold with xml markup.

thanks

+1
source share
1 answer

This conversion is :

 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="text"> <p> <xsl:apply-templates/> </p> </xsl:template> <xsl:template match="bold"> <b><xsl:apply-templates/></b> </xsl:template> </xsl:stylesheet> 

when applied to the provided XML document :

 <xml> <text>This is a <bold>sample</bold> description. Please help me with a sample</text> </xml> 

gives the desired result in HTML :

  <p>This is a <b>sample</b> description. Please help me with a sample</p> 
+2
source

All Articles