I have the following xml format that i want to bind it through a POJO and using JAXB annotations. The XML format is the following:
<datas>
<data>apple<data>
<data>banana<data>
<data>orange<data>
<datas>
And i'm trying to bind the data through the following POJO:
@XmlRootElement()
@XmlAccessorType(XmlAccessType.FIELD)
public class Datas {
@XmlElement
private List<String> data;
//get/set methods
}
And also i try and this POJO:
@XmlRootElement()
@XmlAccessorType(XmlAccessType.FIELD)
public class Datas {
@XmlElement
private List<Data> datas;
//get/set methods
}
//
@XmlRootElement()
@XmlAccessorType(XmlAccessType.FIELD)
public class Data{
@XmlElement
private String data;
//get/set methods
}
In the first case it retrieves only the first data: apple. In the second case doesn't retrieve anything. Could someone help me to provide the appropriate POJO and annotations in order to bind all data?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…