Adding more error handling to starting the XML document