The data inside CDATA to be parsed as Html.
<?xml version="1.0" encoding="utf-8" ?>
<test>
<test1>
<![CDATA[ <B> Test Data1 </B> ]]>
</test1>
<test2>
<![CDATA[ <B> Test Data2 </B> ]]>
</test2>
<test3>
<![CDATA[ <B> Test Data3 </B> ]]>
</test3>
</test>
From the Above input xml I need the output to be parsed as html.
But I am getting the output as
<B>Test Data1</B>
<B>Test Data2</B>
<B>Test Data3</B>
But the actual output I need the text to be in bold.
**Test Data1
Test Data2
Test Data3**
The input is coming from external system.We could not change the text inside CDATA
Parsing as HTML is only possible with an extension function (or with XSLT 2.0 and an HTML parser written in XSLT 2.0) but if you want to create HTML output and want to output the contents of the
testX
elements as HTML then you can do that with e.g.Note however that
disable-output-escaping
is an optional serialization feature not supported by all XSLT processors in all use cases. For instance with client-side XSLT in Mozilla browsers it is not supported.If your have to stay with XSLT 1.0 you have to to run two transformation passes.
First one to copy your xml but remove the CDTA by generate the content with disable-output-escaping="yes" (See answer from @Martin Honnen)
In second path you can access the html part.
But this may be only possible if the html part follow the roles for well formatted xml (xhtml). If not perhaps a input switch as in xsltproc may help to work with html e.g.:
See also: Convert an xml element whose content is inside CDATA