@@ 300-322 (lines=23) @@ | ||
297 | } |
|
298 | } |
|
299 | ||
300 | if ($documentFound === false) { |
|
301 | ||
302 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
303 | $xmlHackUsed = false; |
|
304 | if (\stripos('<?xml', $html) !== 0) { |
|
305 | $xmlHackUsed = true; |
|
306 | $html = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $html; |
|
307 | } |
|
308 | ||
309 | $this->document->loadHTML($html, $optionsXml); |
|
310 | ||
311 | // remove the "xml-encoding" hack |
|
312 | if ($xmlHackUsed) { |
|
313 | foreach ($this->document->childNodes as $child) { |
|
314 | if ($child->nodeType === \XML_PI_NODE) { |
|
315 | /** @noinspection UnusedFunctionResultInspection */ |
|
316 | $this->document->removeChild($child); |
|
317 | ||
318 | break; |
|
319 | } |
|
320 | } |
|
321 | } |
|
322 | } |
|
323 | ||
324 | // set encoding |
|
325 | $this->document->encoding = $this->getEncoding(); |
@@ 147-169 (lines=23) @@ | ||
144 | } |
|
145 | } |
|
146 | ||
147 | if ($documentFound === false) { |
|
148 | ||
149 | // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251 |
|
150 | $xmlHackUsed = false; |
|
151 | if (\stripos('<?xml', $xml) !== 0) { |
|
152 | $xmlHackUsed = true; |
|
153 | $xml = '<?xml encoding="' . $this->getEncoding() . '" ?>' . $xml; |
|
154 | } |
|
155 | ||
156 | $this->document->loadXML($xml, $optionsXml); |
|
157 | ||
158 | // remove the "xml-encoding" hack |
|
159 | if ($xmlHackUsed) { |
|
160 | foreach ($this->document->childNodes as $child) { |
|
161 | if ($child->nodeType === \XML_PI_NODE) { |
|
162 | /** @noinspection UnusedFunctionResultInspection */ |
|
163 | $this->document->removeChild($child); |
|
164 | ||
165 | break; |
|
166 | } |
|
167 | } |
|
168 | } |
|
169 | } |
|
170 | ||
171 | // set encoding |
|
172 | $this->document->encoding = $this->getEncoding(); |