header('Content-Type: text/html; charset=utf-8'); ?>
class SimpleXMLElementExtended extends SimpleXMLElement { private function addCDataToNode(SimpleXMLElement $node, $value = '') { if ($domElement = dom_import_simplexml($node)) { $domOwner = $domElement->ownerDocument; $domElement->appendChild($domOwner->createCDATASection("{$value}")); } } public function addChildWithCData($name = '', $value = '') { $newChild = parent::addChild($name); if ($value) $this->addCDataToNode($newChild, "{$value}"); return $newChild; } public function addCData($value = '') { $this->addCDataToNode($this, "{$value}"); } } function modifyImageAttributes($html) { $html = preg_replace_callback('/