I'm pretty sure $xml is a string, not a SimpleXMLElement