According to RSS Feeds for Instant Articles:
Remember to escape all HTML content by wrapping it within a CDATA section.
So, just wrap the HTML content of content:encoded
with <![CDATA[
and ]]>
:
<content:encoded><![CDATA[<!doctype html> ...</html>]]></content:encoded>
Also:
$content = $item->addChild('content:encoded');$html = $content->addChild('html');
The code above produces the following XML: <encoded><html/></encoded>
Change those lines with something like these:
$content = $item->addChild('content:encoded', null, 'http://purl.org/rss/1.0/modules/content/');$base = dom_import_simplexml($content);$docOwner = $base->ownerDocument;$base->appendChild($docOwner->createCDATASection('<html>Some HTML</html>'));
to produce the following valid XML element:
<content:encoded><![CDATA[<html>Some HTML</html>]]></content:encoded>
For a reference, please, have a look at: