Fixed the XML format issue! Also switched to SimpleXML and DOMDocument