@@ 452-477 (lines=26) @@ | ||
449 | } |
|
450 | } |
|
451 | ||
452 | if ($documentFound === false) { |
|
453 | ||
454 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
455 | $xmlHackUsed = false; |
|
456 | /** @noinspection StringFragmentMisplacedInspection */ |
|
457 | if (\stripos('<?xml', $html) !== 0) { |
|
458 | $xmlHackUsed = true; |
|
459 | $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
460 | } |
|
461 | ||
462 | if ($html !== '') { |
|
463 | $this->document->loadHTML($html, $optionsXml); |
|
464 | } |
|
465 | ||
466 | // remove the "xml-encoding" hack |
|
467 | if ($xmlHackUsed) { |
|
468 | foreach ($this->document->childNodes as $child) { |
|
469 | if ($child->nodeType === \XML_PI_NODE) { |
|
470 | /** @noinspection UnusedFunctionResultInspection */ |
|
471 | $this->document->removeChild($child); |
|
472 | ||
473 | break; |
|
474 | } |
|
475 | } |
|
476 | } |
|
477 | } |
|
478 | ||
479 | // set encoding |
|
480 | $this->document->encoding = $this->getEncoding(); |
@@ 206-229 (lines=24) @@ | ||
203 | } |
|
204 | } |
|
205 | ||
206 | if ($documentFound === false) { |
|
207 | ||
208 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
209 | $xmlHackUsed = false; |
|
210 | /** @noinspection StringFragmentMisplacedInspection */ |
|
211 | if (\stripos('<?xml', $xml) !== 0) { |
|
212 | $xmlHackUsed = true; |
|
213 | $xml = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $xml; |
|
214 | } |
|
215 | ||
216 | $documentFound = $this->document->loadXML($xml, $optionsXml); |
|
217 | ||
218 | // remove the "xml-encoding" hack |
|
219 | if ($xmlHackUsed) { |
|
220 | foreach ($this->document->childNodes as $child) { |
|
221 | if ($child->nodeType === \XML_PI_NODE) { |
|
222 | /** @noinspection UnusedFunctionResultInspection */ |
|
223 | $this->document->removeChild($child); |
|
224 | ||
225 | break; |
|
226 | } |
|
227 | } |
|
228 | } |
|
229 | } |
|
230 | ||
231 | if ( |
|
232 | $documentFound === false |