php: simplexml exception retry

Posted by exceptionhandlingnoob on Stack Overflow See other posts from Stack Overflow or by exceptionhandlingnoob
Published on 2010-04-16T15:31:39Z Indexed on 2010/04/16 15:33 UTC
Read the original article Hit count: 252

Filed under:
|
|

I am querying an API using SimpleXML which will occasionally fail for reasons unknown. I would like to have the script retry up to 5 times. How can I do this? I assume it has something to do with wrapping the object in a try/catch, but I'm not very experienced with this -- have tried to read the manual on exception handling but am still at a loss.

Thanks for any help :)

// set up xml handler
$xmlstr = file_get_contents($request);
$xml = new SimpleXMLElement($xmlstr);

Here is the error message I am receiving:

[function.file-get-contents]: failed to open stream: HTTP request failed!

© Stack Overflow or respective owner

Related posts about php

Related posts about simplexml