I am using the following code:
function GetTwitterAvatar($username){
$xml = simplexml_load_file(\"http://twitter.com/users/\".$username.\".xml\");
$imgurl =
This is an old question, but is still relevant today.
The correct way to handle exceptions when using the oop SimpleXMLElment is like so.
libxml_use_internal_errors(TRUE); // this turns off spitting errors on your screen
try {
$xml = new SimpleXMLElement($xmlStringOfData);
} catch (Exception $e) {
// Do something with the exception, or ignore it.
}