Reputation: 3917
i have an xml which looks like this:
<A>
<C/>
<B/>
<B/>
</A>
in the xml mapping java code i have something like this:
public class A {
@Element(required=false)
private int B;
@Element(required=false)
private int C;
//getters and setters...
}
but i am getting an error like this: org.simpleframework.xml.core.PersistenceException: Element 'B' declared twice at line 1
how do i get rid of this problem? solution from anyone is highly appreciated.
thanks in advance.
Upvotes: 1
Views: 1294
Reputation: 21
public class A {
@ElementList(inline=true,required=false, entry="B")
private List<Integer> B;
@ElementList(inline=true,required=false, entry="C")
private List<Integer> C;
//getters and setters...
}
Upvotes: 2
Reputation: 23181
In your Xml you have 2 B elements so in your POJO you need to have a collection of some sort (i.e. a List) for B since it can appear in the XML 0 or more times.
Upvotes: 2