Answer the question
In order to leave comments, you need to log in
How to check simplexml_load_file for successful loading?
As a standard script I load xml from not the most stable server.
$linkxml="http://ссылка.ру";
$xml = simplexml_load_file($linkxml);
Warning: simplexml_load_file() [function.simplexml-load-file]: http://ссылка.ру:6: parser error : Opening and ending tag mismatch: hr line 5 and body in /home/public_html/ссылка/update.php on line 106
$linkxml="http://ссылка.ру";
$xml = simplexml_load_file($linkxml);
if (!simplexml_load_file($linkxml)) {echo 'файл не получен';} else {$xml = "не могу придумать как получить сюда данные из simplexml_load_file";}
Answer the question
In order to leave comments, you need to log in
The documentation says
And the warning that this occurs because of incorrect XML, which is what is written in the LOGS. In the code, check as follows: if ($xml !== false) {...}
If you return invalid XML, then this will not change over time (most likely), so restarting and further attempts to load will not lead to anything. And if you really want to try to download again, then try
do {
$xml = simplexml_load_file(...);
} while ($xml === false);
// $xml загружен.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question