I am using simplxmlconvertor with retrofit in my app to parse xml response from API. Success response from API is given below.
<Success>
<id>sf98hjf</id>
</Success>
And error response is given below.
<Error>
<message>No data found</message>
</Error>
My model class to parse success response is given below
@Root(name = "Success")
public class ResponseModel {
@Element
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
This works fine when I get success response. But I want to parse error response as well to show error message to user. How can I achieve the same. Now I am getting exception since the structure doesn't match. Thanks in advance.