[Simple-support] @ElementList issue
Brought to you by:
niallg
|
From: Chris J. <ch...@gm...> - 2012-11-29 20:46:56
|
simpleframework ElementException: Element subscriber does not have a match
in class com.xyz.dazzler3.model.SubscribersList at line 1
I'm invoking this with:
*SubscribersList response = serializer.read(SubscribersList.class,
newStringReader(XMLString));
*
...where XMLString is the xml I'm reading.
I'm using @ElementList to define the List of Subscribers and I have a class
to define each individual subscriber. Seems it should be "simple", but I'm
not seeing what is wrong.
I have tried variations on the entry attribute, but nothing seems to work.
Anyone see my glaring error?
simple-xml-2.6.7.jar in my libs dir.
Thanks for any help/tips,
Chris.
*The Subscribers object (note plural):*
package com. xyz.dazzler3.model;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root(name="subscribers")
public class SubscribersList {
@ElementList(entry="Subscriber", inline=true)
private List<Subscriber> list;
public List<Subscriber> getList() {
return list;
}
public void setList(List<Subscriber> list) {
this.list = list;
}
}
*The Subscriber Object:*
package com. xyz.dazzler3.model;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
@Root(name="subscriber")
public class Subscriber {
@Element(name="id")
private String id;
@Element(name="fname")
private String fname;
@Element(name="lname"
private String lname;
@Element(name="phone")
private String phone;
@Element(name="countryISO")
private String countryISO;
@Element(name="mac", required=false)
private String mac;
@Element(name="evid")
private String evid;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getCountryISO() {
return countryISO;
}
public void setCountryISO(String countryISO) {
this.countryISO = countryISO;
}
public String getMac() {
return mac;
}
public void setMac(String mac) {
this.mac = mac;
}
public String getEvid() {
return evid;
}
public void setEvid(String evid) {
this.evid = evid;
}
}
*Sample XML:*
<?xml version="1.0" encoding="utf-8"?>
<subscribers>
<subscriber>
<id>1234567890</id>
<fname>Roberto</fname>
<lname>Jackson</lname>
<phone>510-419-2204</phone>
<countryISO>USA</countryISO>
<mac></mac>
<evid>1234567890</evid>
</subscriber>
<subscriber>
<id>4567890123</id>
<fname>Paul</fname>
<lname>Fults</lname>
<phone>201-433-5674</phone>
<countryISO>USA</countryISO>
<mac></mac>
<evid>4567890123</evid>
</subscriber>
</subscribers>
|