Sulla causa non saprei, ma potresti aggiungere un controllo sulla stringa vuota ad esempio:

Codice PHP:
...
if(empty(
$xml)) {
    return 
false;
}
...