Well, there are a couple of things worth pointing out here:
Firstly, you've annotated the pokemon
field in the Data
class, but this is not going to work unless you supply the name of the xml tag the field should be bound up to. SimpleXML won't know that you actually mean the bind up Pkmn
to pokemon
. In short, add:
@Element(name="Pkmn") private Pokemon pokemon;
Last time I checked, SimpleXML does support auto-binding, but that will require the @Default
annotation and the field names have to match the xml tags.
That being said, the safest option here is to not use @Default
and explicitly supply the name with every annotation. That is, go through your Pokemon
class and declare the name for every @Element
annotation. For example:
...
@Element(name="ablt") private String abilities;
...
After that, you should be close to have working code. To clean up, you may want to remove strict=false
from the @Root
declaration of your Data
class. That was probably your initial attempt to bypass the ValueRequiredException
? If the Data
tag not having a Pkmn
tag is a valid scenario, then potentially leave it in there, but otherwise you should remove it to avoid undesired side effects.