You need to put something like this:
@XmlElement(name = "ip_addresses")
private IPAddresses ipAddresses;
and IPAddresses POJO class:
@XmlRootElement(name = "ip_addresses")
@XmlAccessorType(XmlAccessType.FIELD)
public class IPAddresses implements Serializable {
private final static long serialVersionUID = 1L;
@XmlElement(name = "ip_address")
private List<IPAddress> ipAddresses;
public List<IPAddress> getIpAddresses() {
return ipAddresses;
}
public void setIpAddresses(List<IPAddress> ipAddresses) {
this.ipAddresses = ipAddresses;
}
}
Where IPAddress is another POJO class that describes the structure of the individual element.
@XmlRootElement(name = "ip_address")
@XmlAccessorType(XmlAccessType.FIELD)
public class IPAddress implements Serializable {
private final static long serialVersionUID = 1L;
@XmlValue
protected String content;
@XmlAttribute(name = "type")
protected String type;
public void setContent(String content) {
this.content = content;
}
public String getContent() {
return content;
}
public void setType(String content) {
this.type = type;
}
public String getType() {
return type;
}
}
EDIT
To print them do something like this:
for (IPAddress ipAddress in custinfo.getIpAddresses().getIpAddresses()) {
System.out.println("value: " + ipAddress.getContent());
System.out.println("type: " + ipAddress.getType());
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…