Getting SAXParseException while trying to parse xml with &

186 views Asked by At

I am trying to parse XML response into Java object. Here is the sample xml response

Response

        <SavedSearch>
            <Id>8</Id>
            <Name>My Outstanding & Overdue mail</Name>
        <SavedSearch>

Here is my Java Pojo object where i am trying to map response

JavaResponse.java

    @XmlRootElement(name = "SavedSearch")
    public class MailSavedSearchRO {
    private String id;
    private String name;
    @XmlElement(name = "Id")
    public String getId() {
      return id;
    }

    public void setId(String id) {
      this.id = id;
    }

    @XmlElement(name = "Name")
    public String getName() {
      return name;
    }

    public void setName(String name) {
      this.name = name;
    }

But I am getting org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.I went through some solutions online but it was suggested that "&" should be replaced with ampersand. But the xml response is external entity and cant be modified from my end. Can anyone suggest how i can parse xml containing "&" without modifying xml response.

0

There are 0 answers