Switched from DOM to SimpleXML and added error handling.