Implementing code to try and fix bad XML