Replacing bad xml code with good xml code