在通过php解析xml时如何处理500内部服务器错误?

So, how would i go about checking a 500 internal server error, then printing a message like

if(errormessage){
//print custom message
} else
{
// continue with code
}

Something like that? How would i be able to do that? Currently i'm parsing xml with simplexml and for some stuff its parsing from certain profiles it gives a 500 error.

I basically want to print a message if it comes across the error, else continue with execution.

the errors i get are

Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in F:\xampp\htdocs\index.php on line 6

Warning: simplexml_load_string(): in F:\xampp\htdocs\index.php on line 6

Warning: simplexml_load_string(): ^ in F:\xampp\htdocs\index.php on line 6

Fatal error: Call to a member function attributes() on a non-object in F:\xampp\htdocs\index.php on line 7

Thank you.

surround with try catch and print your message in catch block

Exception Handling