I have a page that will basically be used to concatenate a bunch of xml files, it will act as glue that binds them together. There's a small chance the xml files that are being combined might not be well formed because the user will have access.
I'm trying to basically rewrite a live file if there are no warnings / errors thrown in a specific set of code.
So far I have:
try {
$first = simplexml_load_file( 'file.xml' );
} catch ( Exception $e ) {
$write = false;
}
if ( !$write ) {
// write to live file.
}
This obviously catches error exceptions, but sometimes function invocations can return warnings and not errors per se, what can I use to catch errors, basically only write if no warnings and errors have been thrown in the try block?
Example of a warning being thrown:
Warning: simplexml_load_file() parser error : Start tag expected, '<'