Added conditional handling for XML response data instead of JSON