@@ 150-172 (lines=23) @@ | ||
147 | } |
|
148 | } |
|
149 | ||
150 | if ($documentFound === false) { |
|
151 | ||
152 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
153 | $xmlHackUsed = false; |
|
154 | /** @noinspection StringFragmentMisplacedInspection */ |
|
155 | if (\stripos('<?xml', $xml) !== 0) { |
|
156 | $xmlHackUsed = true; |
|
157 | $xml = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $xml; |
|
158 | } |
|
159 | ||
160 | $this->document->loadXML($xml, $optionsXml); |
|
161 | ||
162 | // remove the "xml-encoding" hack |
|
163 | if ($xmlHackUsed) { |
|
164 | foreach ($this->document->childNodes as $child) { |
|
165 | if ($child->nodeType === \XML_PI_NODE) { |
|
166 | /** @noinspection UnusedFunctionResultInspection */ |
|
167 | $this->document->removeChild($child); |
|
168 | ||
169 | break; |
|
170 | } |
|
171 | } |
|
172 | } |
|
173 | } |
|
174 | ||
175 | // set encoding |
@@ 427-449 (lines=23) @@ | ||
424 | } |
|
425 | } |
|
426 | ||
427 | if ($documentFound === false) { |
|
428 | ||
429 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
430 | $xmlHackUsed = false; |
|
431 | /** @noinspection StringFragmentMisplacedInspection */ |
|
432 | if (\stripos('<?xml', $html) !== 0) { |
|
433 | $xmlHackUsed = true; |
|
434 | $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
435 | } |
|
436 | ||
437 | $this->document->loadHTML($html, $optionsXml); |
|
438 | ||
439 | // remove the "xml-encoding" hack |
|
440 | if ($xmlHackUsed) { |
|
441 | foreach ($this->document->childNodes as $child) { |
|
442 | if ($child->nodeType === \XML_PI_NODE) { |
|
443 | /** @noinspection UnusedFunctionResultInspection */ |
|
444 | $this->document->removeChild($child); |
|
445 | ||
446 | break; |
|
447 | } |
|
448 | } |
|
449 | } |
|
450 | } |
|
451 | ||
452 | // set encoding |