aspose file tools*
The moose likes XML and Related Technologies and the fly likes binding to List  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "binding to List  " Watch "binding to List  " New topic

binding to List

Owais Zahid

Joined: Nov 11, 2009
Posts: 21
I have an xml like this :


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

How can i unmarshal my xml to my class "Zoo" that contains a "List<Animal> animalList".

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

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12675
Why are you saying "unmarshal"?

We usually speak of parsing XML so it sounds like there are some additional requirements you are not describing.


Java Resources at
Owais Zahid

Joined: Nov 11, 2009
Posts: 21
Bill , i am using JAXB that is why i used the terminology of "un-marshalling".

If you can help me that what sort of Annotations (XML ELEMENT or INTERCEPTOR ) i need to write in order to map all the tags (like lion , zebra blah blah) to my list of animals.

subject: binding to List
Similar Threads
generic question
Coupling and cohesion
Generics problem- why not taking Animal, Object and super of Dog
Getting a typed Iterator for Generics
Parent child object problem