clean up and reformat the xml