I am using Perl to create an XML file and then using
use XML::LibXML;
In one part of code I need to write some explanation in one node by
$writer->characters("<![CDATA[$xmlFile]]>");
What I have as an output is
<![CDATA[example.xml]]>
But what expect to have would be
<![CDATA[example.xml]]>
I have checked <
and >
, but it does not work at all. Because istead of symbol &
again it prints out encoding, too.
Does anyone have an idea how to come over?
Don't try to use characters
to write a CDATA section directly; it generates text, not elements and not special constructs like CDATA sections, PIs, or comments. Instead (assuming $writer
is an XML::Writer
) you can do $writer->cdata($xmlFile)
.