Quantcast
Viewing all articles
Browse latest Browse all 16

Loading data from XML: How to skip error in/incorrect XML file?

I have in database several XML feeds which I regularly checking. How I do process data:

I load these XML links from DB and in loop through the simplexml_load_file() I am parsing data. But sometimes the script is terminated because of error caused by wrong format of XML file, for example:

Warning: simplexml_load_file() [function.simplexml-load-file]: URL_ADDRESS:1: parser error : Invalid XML encoding name in path_to_script on line 98

Warning: simplexml_load_file() [function.simplexml-load-file]: <?xml version="1.0" encoding=""?> in path_to_scriptp on line 98

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in path_to_script on line 98

Warning: Invalid argument supplied for foreach() in path_to_script on line 99

Is there any way to handle this error and when an error is occurred, then would be this XML feed skipped and the script would continue with the next one?


Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>