Finished the generateXML function