Change XML file writing to preserve things like tags etc