i wrote a php-script which is loading the xml/html of a given url, parses it and writes it to an database. Since some hours ago I’m getting the strange mentioned error, not all the times but definitely too much.
Do you have any suggestions as to what is going wrong?
Here are the lines of code which are supposed to cause the logged error:
libxml_use_internal_errors( true );
$data = file_get_contents($item->get_link());
$dom = new DOMDocument();
$dom->loadHTML($data);
Well, there’s not much to work off, so here’s some possible issues:
1)
$item->get_link()is not returning a valid URL2) You assume
file_get_contentswill always get the data. What happens when there’s a network issue? The server is down? You need to make sure$datais valid before doing something with it.3)
$datais not parse-able by the dom parser, possibly for one of the previous reasons.