It's returning
( ! ) Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Misplaced DOCTYPE declaration in Entity, line: 3 in C:\wamp\www\source.php on line 8
The code:
<?php
$url = "http://www.some-plain-html-website.com";
$content = file_get_contents($url);
$dom = new DOMDocument;
$dom->loadHTML($content);
?>
For some reason it wont parse $content. If i make content a string like $content = ""; and i parse it by element tag name it works no problem however if i give it the return of file_get_content() method it yields that error.
The documentation for file_get_contents() says it returns a string but for some reason its not working i even tried $content = (string)file_get_contents($url);
Same thing thanks in advance for all the help.
In many cases it is advisable to use libxml_use_internal_errors(true);
before $dom->loadHTML($content);
This way a warning will not be thrown, and the page is loaded anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With