Added option to use xml or json