Fixed XML writing