Creating innerHTML and outerHTML<?phpclass DOMHTMLElement extends DOMElement{ function __construct() { parent::__construct();} public function innerHTML() { $doc = new DOMDocument(); foreach ($this->childNodes as $child){ $doc->appendChild($doc->importNode($child, true)); } $content = $doc->saveHTML(); return $content; } public function outerHTML() { $doc = new DOMDocument(); $doc->appendChild($doc->importNode($this, true)); $content = $doc->saveHTML(); return $content; }}$dom = DOMDocument::loadHTMLFile($file);$dom->registerNodeClass('DOMElement','DOMHTMLElement'); if($dom){ $xpath = new DOMXpath($dom); $regions = $xpath->query("//*[contains(@class, 'editable')]"); $content = ''; foreach($regions as $region){ $content .= $region->outerHTML(); } return $content; }else{ throw new Exception('Cannot parse HTML. Please verify the syntax is correct.');}?>