@@ 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 |
@@ 379-401 (lines=23) @@ | ||
376 | } |
|
377 | } |
|
378 | ||
379 | if ($documentFound === false) { |
|
380 | ||
381 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
382 | $xmlHackUsed = false; |
|
383 | /** @noinspection StringFragmentMisplacedInspection */ |
|
384 | if (\stripos('<?xml', $html) !== 0) { |
|
385 | $xmlHackUsed = true; |
|
386 | $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
387 | } |
|
388 | ||
389 | $this->document->loadHTML($html, $optionsXml); |
|
390 | ||
391 | // remove the "xml-encoding" hack |
|
392 | if ($xmlHackUsed) { |
|
393 | foreach ($this->document->childNodes as $child) { |
|
394 | if ($child->nodeType === \XML_PI_NODE) { |
|
395 | /** @noinspection UnusedFunctionResultInspection */ |
|
396 | $this->document->removeChild($child); |
|
397 | ||
398 | break; |
|
399 | } |
|
400 | } |
|
401 | } |
|
402 | } |
|
403 | ||
404 | // set encoding |