Take this XML.
Is there a way for me to transform the contents of the CDATA section with XSLT?
Take this XML.
Is there a way for me to transform the contents of the CDATA section with XSLT?
XSLT handles CDATA sections as just normal text, so you can treat them as you would text nodes. Note that XSLT does not retain CDATA sections as separate from surrounding text. Thus if you have
<foo>bar <![CDATA[baz]]> qux</foo>
The source tree will be
Read this article - CDATA Sections
SUMMARY:Within the XSLT stylesheet, the CDATA section is purely a utility to stop you from having to escape all the '<' etc. The goal you're aiming for is copying something that you have in your XML source directly into your HTML output. The xsl:copy-of element is designed precisely for this purpose. xsl:copy-of will give an exact copy of whatever you select, including attributes and content.
XML document.
<?xml version="1.0" encoding="iso-8859-1"?>
<know>
<title/>
<topic title="" href="">
<![CDATA[
Text
]]>
</p>
</topic>
</know>
xsl Document.
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="know">
<xsl:value-of select="title"/>
<xsl:for-each select="topic">
<xsl:value-of select="@title"/>
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>