Xml parsing and writing by the controller