From: Robert Kaiser Date: Sun, 16 Apr 2017 23:13:06 +0000 (+0200) Subject: Merge branch 'master' of linz:/srv/git/php-utility-classes X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=commitdiff_plain;h=f95a81fc8e3b7a98544622d8509ea0f1d79e4df6;hp=585f33e6f4a37642e4816d0465ab1112b670f9b3 Merge branch 'master' of linz:/srv/git/php-utility-classes --- diff --git a/classes/document.php-class b/classes/document.php-class index 3e39f0a..dbad743 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -299,8 +299,13 @@ class ExtendedDocument extends DOMDocument { public function appendHTMLMarkup($htmldata, $parentNode = null) { if (is_null($parentNode)) { $parentNode =& $this; } - // XXX: just a workaround for now! - $parentNode->appendChild($this->createCDATASection($htmldata)); + // Use loadHTML() to parse and turn the markup into proper HTML. + $tmpdoc = new ExtendedDocument; + // The XML line is needed to tell the parser that we need UTF-8 parsing. + $tmpdoc->loadHTML(''.$htmldata.''); + foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) { + $parentNode->appendChild($this->importNode($child, true)); + } } public function appendXMLMarkup($xmldata, $parentNode = null) {