Skip to content Skip to sidebar Skip to footer

Can We Insert Html Tags In Xsl Variable

I just want to confirm whether we can insert html tags inside the xsl variable? example hiiii

Solution 1:

Do not use value-of, which gets the text value of the selected node. Instead use copy-of, which copies the entire tree (nodes and all) into the output:

<xsl:copy-of select="$htmlContent"/>

Here is a full example:

<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0"><xsl:variablename="htmlContent"><html><body>hiiii</body></html></xsl:variable><xsl:templatematch="/"><xsl:elementname="htmlText"><xsl:copy-ofselect="$htmlContent"/></xsl:element></xsl:template></xsl:stylesheet>

This will always produce the xml:

<htmlText><html><body>hiiii</body></html></htmlText>

Post a Comment for "Can We Insert Html Tags In Xsl Variable"