@@ 381-403 (lines=23) @@ | ||
378 | } |
|
379 | } |
|
380 | ||
381 | if ($documentFound === false) { |
|
382 | ||
383 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
384 | $xmlHackUsed = false; |
|
385 | if (\stripos('<?xml', $html) !== 0) { |
|
386 | $xmlHackUsed = true; |
|
387 | $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
388 | } |
|
389 | ||
390 | $this->document->loadHTML($html, $optionsXml); |
|
391 | ||
392 | // remove the "xml-encoding" hack |
|
393 | if ($xmlHackUsed) { |
|
394 | foreach ($this->document->childNodes as $child) { |
|
395 | if ($child->nodeType === \XML_PI_NODE) { |
|
396 | /** @noinspection UnusedFunctionResultInspection */ |
|
397 | $this->document->removeChild($child); |
|
398 | ||
399 | break; |
|
400 | } |
|
401 | } |
|
402 | } |
|
403 | } |
|
404 | ||
405 | // set encoding |
|
406 | $this->document->encoding = $this->getEncoding(); |
@@ 94-116 (lines=23) @@ | ||
91 | } |
|
92 | } |
|
93 | ||
94 | if ($documentFound === false) { |
|
95 | ||
96 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
97 | $xmlHackUsed = false; |
|
98 | if (\stripos('<?xml', $xml) !== 0) { |
|
99 | $xmlHackUsed = true; |
|
100 | $xml = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $xml; |
|
101 | } |
|
102 | ||
103 | $this->document->loadXML($xml, $optionsXml); |
|
104 | ||
105 | // remove the "xml-encoding" hack |
|
106 | if ($xmlHackUsed) { |
|
107 | foreach ($this->document->childNodes as $child) { |
|
108 | if ($child->nodeType === \XML_PI_NODE) { |
|
109 | /** @noinspection UnusedFunctionResultInspection */ |
|
110 | $this->document->removeChild($child); |
|
111 | ||
112 | break; |
|
113 | } |
|
114 | } |
|
115 | } |
|
116 | } |
|
117 | ||
118 | // set encoding |
|
119 | $this->document->encoding = $this->getEncoding(); |