+ private function html_to_xml($html) {
+ $xmlDoc = new DOMDocument();
+
+ // Handle warnings and errors when loading invalid HTML.
+ $xml_errors_value = libxml_use_internal_errors(true);
+ $xmlDoc->loadHTML($html);
+ foreach (libxml_get_errors() as $xml_error) {
+ $this->log_xml_error($xml_error);
+ }
+ libxml_clear_errors();
+ libxml_use_internal_errors($xml_errors_value);
+
+ return $xmlDoc;
+ }
+