require an exact match for the list entries
[php-utility-classes.git] / classes / document.php-class
index 3e39f0acefdcd7ddaa852ffde3e15bb1689ccbc6..dc0d91981d9051b22f5e97ac62eb57639d32e03a 100755 (executable)
@@ -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('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><body>'.$htmldata.'</body></html>');
+    foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) {
+      $parentNode->appendChild($this->importNode($child, true));
+    }
   }
 
   public function appendXMLMarkup($xmldata, $parentNode = null) {
@@ -454,7 +459,7 @@ class ExtendedDocument extends DOMDocument {
     $select->setAttribute('name', $name);
     if (!is_null($id)) { $select->setAttribute('id', $id); }
     foreach ($options as $key => $desc) {
-      $select->appendElementOption($key, $desc, ($key == $default));
+      $select->appendElementOption($key, $desc, ($key === $default));
     }
     return $select;
   }