I am using the following code:
function GetTwitterAvatar($username){
$xml = simplexml_load_file(\"http://twitter.com/users/\".$username.\".xml\");
$imgurl =
My little code:
try {
libxml_use_internal_errors(TRUE);
$xml = new SimpleXMLElement($xmlString);
echo ''.htmlspecialchars($xml->asXML()).'
';
} catch (Exception $e) {
echo 'Caught exception: ' . $e->getMessage() . chr(10);
echo 'Failed loading XML: ' . chr(10);
foreach(libxml_get_errors() as $error) {
echo '- ' . $error->message;
}
}
Result example:
Caught exception: String could not be parsed as XML
Failed loading XML:
- Opening and ending tag mismatch: Body line 3 and Bod-y