As the title says, I am struggling with add cdata text in my code. And yes, I tried the most popular example here on stackoverflow but there the class is extended and some different approach is used. What I did so far is this. Not sure also if it is good practice to just concatenate a <![CDATA[ my text here ]]>
as a simple string.
$xml = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\" ?><SHOP></SHOP>");
foreach ($res as $item) {
$shopitem = $xml->addChild("SHOPITEM");
$shopitem->addChild("ITEM_ID", $item['item_id']);
$shopitem->addChild("ITEMGROUP_ID", $item['itemgroup_id']);
$shopitem->addChild("PRODUCTNAME", $item['productname']);
$shopitem->addChild("MANUFACTURER", TEXT HERE SHOULD BE CDATA);
}
Header('Content-type: text/xml');
print($xml->asXML());