Fix error handling for XML Parsing