I need to wrap some descriptions into <![CDATA[...]]>
.
What I'm doing:
public function cdata() {
$description = 'Den snabba bruna räven hoppade över den lata hunden';
$channel = array();
$channel['item'] = array(
'g:description' => '<![CDATA['.$description.']]>',
);
$this->RequestHandler->renderAs($this, 'xml');
$this->set('_rootNode', 'rss');
$this->set('xmlns:g', 'http://base.google.com/ns/1.0');
$this->set([
'channel' => $channel,
]);
$this->set('_serialize', ['xmlns:g','channel']);
}
What I'm getting:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0">
<channel>
<item>
<g:description><![CDATA[Den snabba bruna räven hoppade över den lata hunden]]></g:description>
</item>
</channel>
</rss>
What I want:
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:g="http://base.google.com/ns/1.0">
<channel>
<item>
<g:description><![CDATA[Den snabba bruna räven hoppade över den lata hunden]]></g:description>
</item>
</channel>
</rss>
Problem:
The CDATA gets htmlspecialchars'd, with <
and >
converted to <
and >
. Here's an example of what I need (source), see the Second example demonstrates the use of CDATA section.
I googled all kinds of combinations of cakephp 3
, xml
and cdata
, but found nothing, particularly, checked the documentation and here. Please help!