I thinks this is a better way
$use_errors = libxml_use_internal_errors(true);
$xml = simplexml_load_file($url);
if (false === $xml) {
// throw new Exception("Cannot load xml source.\n");
}
libxml_clear_errors();
libxml_use_internal_errors($use_errors);
more info: http://php.net/manual/en/function.libxml-use-internal-errors.php