I can’t generate XML to have HTML-wrapped content in the <![CDATA[...title...]]>
.
CDATA escapes me. Do you have experience with it?
Can you give some code that shows how you’re generating the XML that is working for you? There are many ways to do this, and the answer to your question will depend on how your existing code works.
$xml_items = [];
foreach ($query as $item) {
$xml_items[] = [
'ITEM_ID' => $item->catalog_number,
'PRODUCT' => $item->name,
'DESCRIPTION' => $item->description,
];
}
$xml_data = [
'SHOP' => [
'SHOPITEM' => $xml_items,
],
];
$xml = Xml::build($xml_data, ['pretty' => true, 'encoding' => 'UTF-8']);
$xml->asXML(WWW_ROOT . 'feeds' . DS . 'feed.xml');
I would like to have a description column in CDATA.
I have a solution for this in my system based on src_Utility_Xml.php.patch · GitHub
Thank You and how replace the class XML if store file in /app/Utility/Xml.php
?
I don’t want to make changes in the vendor directory.
I made my own XML class, which extended the Cake one but overloaded the function in question.
1 Like
I understand how I overload a class function?
That’s a PHP question, not a Cake question. See https://www.php.net/manual/en/language.oop5.overloading.php.
1 Like