Moved the generation of the XML in the controller