Having created an XML feed from an API, I am aware that I have to use CDATA for a couple of the nodes. Some are working fine and without any issues, though some appear to be missing content and showing ]]> to the end.
$introduction = substr( $property['description'], 0 , 250 ); // Truncate Description at 250 characters
$description = $property['description'];
$ltd_introduction = $xml->createElement( 'introduction', htmlspecialchars( "<![CDATA[$introduction]]>" ) );
$ltd_description = $xml->createElement( 'description', htmlspecialchars( "<![CDATA[$description]]>" ) );
The newly created XML feed shows:
<introduction>
<![CDATA[Lorem ipsum dolor sit amet]]>
</introduction>
<description>
<![CDATA[Lorem ipsum dolor sit amet]]>
</description>
But on the page when it is rendered I a mixture of:
Lorem ipsum dolor sit amet
lorem ipsum dolor sit amet]]>
sit amet]]>
I'm aware there are likely to be special characters, and there are <br>
which on the XML feed show as <br >
Additionally, there will be letters that contain accents.
Having read various answers, I thought it necessary to add the CDATA section and htmlspecialcharacters, but still appear to be having the issues.