Is it possible to catch simplexml file errors? I'm connecting to a webservice that sometimes fails, and I need to make the system skip a file if it returns some http error or something similar.
Using @
is just plain dirty.
If you look at the manual, there is an options parameter:
SimpleXMLElement simplexml_load_file ( string $filename [, string $class_name = "SimpleXMLElement" [, int $options = 0 [, string $ns = "" [, bool $is_prefix = false ]]]] )
All option list is available here: http://www.php.net/manual/en/libxml.constants.php
This is the correct way to suppress warnings:
$xml = simplexml_load_file('file.xml', 'SimpleXMLElement', LIBXML_NOWARNING);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With