I am trying to parse the content of any url. Which should not content any html code. This works fine, but gives bunch of error while reading the content on url given. How to
You can use libxml_use_internal_errors() and do the following:
libxml_use_internal_errors(true);
$doc->loadHTMLFile($url);
libxml_clear_errors();
As Peehaa noted in the comments below, it's a good idea to reset the state of errors. You can do it as below:
$errors = libxml_use_internal_errors(true); //store
$doc->loadHTMLFile($url);
libxml_clear_errors();
libxml_use_internal_errors($errors); //reset back to previous state
Here's how it works:
Demo!