@ 2019-08-28T12:13:30Z <?php
class SimpleXMLExtended extends SimpleXMLElement {
public function addCData($cdata_text) {
$node = dom_import_simplexml($this);
$no = $node->ownerDocument;
$node->appendChild($no->createCDATASection($cdata_text));
}
}
$oXML = new SimpleXMLExtended('<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0" />');
$oChannel = $oXML->addChild('channel');
$oChannel->addChild('title', 'TEST');
$oProduct = $oChannel->addChild('item');
$oProduct->addChild('condition1', 'new', 'http://base.google.com/ns/1.0');
$oProduct->addChild('condition2', 'new', 'http://base.google.com/ns/1.0');
$oProduct->product_type = null;
$oProduct->product_type->addCData('TEST - HOW TO GET NAMESPACE HERE');
$oProduct->addChild('condition3', 'new', 'http://base.google.com/ns/1.0');
echo $oXML->asXML();
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.1.25 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.33 , 8.2.0 - 8.2.29 , 8.3.0 - 8.3.26 , 8.4.1 - 8.4.13 <?xml version="1.0"?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"><channel><title>TEST</title><item><g:condition1>new</g:condition1><g:condition2>new</g:condition2><product_type><![CDATA[TEST - HOW TO GET NAMESPACE HERE]]></product_type><g:condition3>new</g:condition3></item></channel></rss>
preferences:dark mode live preview ace vim emacs key bindings
145.85 ms | 408 KiB | 5 Q