Fix XML writing