use SimpleXMLElementExtended as GlobalSimpleXMLElementExtended;
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED );
$time_start = microtime(true);
class SimpleXMLElementExtended extends SimpleXMLElement
{
/**
* Add value as CData to a given XML node
*
* @param SimpleXMLElement $node SimpleXMLElement object representing the child XML node
* @param string $value A text to add as CData
* @return void
*/
private function addCDataToNode(SimpleXMLElement $node, $value = '')
{
if ($domElement = dom_import_simplexml($node))
{
$domOwner = $domElement->ownerDocument;
$domElement->appendChild($domOwner->createCDATASection("{$value}"));
}
}
/**
* Add child node with value as CData
*
* @param string $name The child XML node name to add
* @param string $value A text to add as CData
* @return SimpleXMLElement
*/
public function addChildWithCData($name = '', $value = '')
{
$newChild = parent::addChild($name);
if ($value) $this->addCDataToNode($newChild, "{$value}");
return $newChild;
}
/**
* Add value as CData to the current XML node
*
* @param string $value A text to add as CData
* @return void
*/
public function addCData($value = '')
{
$this->addCDataToNode($this, "{$value}");
}
}
function xml_adopt($root, $new) {
$node = $root->addChild($new->getName(), (string) $new);
foreach($new->attributes() as $attr => $value) {
$node->addAttribute($attr, $value);
}
foreach($new->children() as $ch) {
xml_adopt($node, $ch);
}
}
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL,'https://www.strefakierowcy.pl/tools/market/google2.xml');
// $fp = fopen( 'google-feed.xml', 'w+' );
// curl_setopt( $ch, CURLOPT_FILE, $fp );
// curl_exec ( $ch );
// curl_close ( $ch );
// fclose( $fp );
unlink('google-feed-parsed.xml');
$xml_feed = new GlobalSimpleXMLElementExtended('
Total Execution Time: '.$execution_time.' s
';