Tuesday, 7 June 2011

XSLT - Displaying HTML content within XML tags

Rather then using the value-of tag, utilise the copy-of tag instead.


XML File
<?xml version="1.0"?>
<?xml-stylesheet type="text/xml" href="stylesheet.xsl"?>
<test><p><b>This is bold text in a paragraph</b></p></test>



XSL File
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:copy-of select="test" />
    <xsl:value-of select="test" />
  </xsl:template>
</xsl:stylesheet>



Output

This is bold text in a paragraph


This is bold text in a paragraph

No comments: