I have an XML document that I need to convert to HTML. The XML content is as follows:
<root> <enc>Sample Text : <d>Hello</d> <e>World</e></enc> <dec> Sample Text : <d>Hello</d> <e>World</e> </dec> </root>
I need to apply a template for the value in the "enc" element, as I did for the "dec" element in the following xslt.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" > <xsl:template match="root"> <html> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="dec"> <xsl:apply-templates/> </xsl:template> <xsl:template match="enc"> <xsl:value-of select="." disable-output-escaping="no" /> <br/> </xsl:template> <xsl:template match="d"> <b> <xsl:value-of select="."/> </b> </xsl:template> <xsl:template match="e"> <i> <xsl:value-of select="."/> </i> </xsl:template> </xsl:stylesheet>
Actual output for the above XSLT:
Sample text: <d>Hello</d> <e>World</e>
Sample text: Hello World
Required Result:
Sample text: Hello World
Sample text: Hello World
Please help me convert the encoded xml value only with XSLT.
Thanks in advance.
user313495
source share