Fixed buggy error handling for XML response