Handling exceptions for XML parsing