users@jaxb.java.net

Jaxb unmarshalling to generic list of base class type

From: owais zahid <owais_zahid_at_hotmail.com>
Date: Thu, 25 Mar 2010 11:43:32 +0500

I have an xml like this :

<Zoo>
<Lion>
<Zebra>
....
</Zoo>

----------------------------------
And on my java project , i have an abstract class "Animal" and all the animals (like lion , zebra ) extends from it.

I am using JAXB , how can i unmarshal my xml to my class "Zoo" that contains a "List<Animal> animalList" ?


 public
 class Zoo
{
.....
protected List<Animal> animalList;
}

public class Lion extends Animal {
...
}
 

I hope, i explained my scenario clearly. Can someone please help me. So far i am unable to successfully unmarshal my xml file to List of Animals. Please help

-Owais
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969