javaandroidxml-parsingxml-deserializationsimple-framework

Element 'title' is already used with @org.simpleframework.xml.ElementList


i am deserialising xml using SimpleXml api.
But receiving an exception

###Exception:

Element 'title' is already used with @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=false, name=title, required=true, type=void) on field 'citationList' private java.util.List com.example.app.Entity.Citations.citationList at line 1

###My Xml:
<citations>
 <title>xyz xyz</title>
 <title>xyz xyz</title>
 <title>xyz xyz</title>
 <title>xyz xyz</title>
 <title>xyz xyz</title>
 <title>xyz xyz</title>
</citations>

###My class: Citations

@Root(name = "citations")
public class Citations {

    @ElementList(name = "title")
    private List<String> citationList;


    public List<String> getCitationList(){
        return citationList;
    }

    public void setCitationList(List<String> citationList) {
        this.citationList = citationList;
    }
}

Please help me out of this, how do i deserilize it using SimpleXml api. What annotation should i use in my class. I am receiving the same xml as i have mentioned above.


Solution

  • i got an answer for this , use the annotation attributes as follows.

    @Root(name = "citations")
    public class Citations {
        public Citations() {}
        
        @ElementList(inline = true, entry = "citation")
        private List<String> citationList;
        
        public List<String> getCitationList() {
            return citationList;
        }
        
        public void setCitationList(List<String> citationList) {
            this.citationList = citationList;
        }
    }