users@jaxb.java.net

RE: How can I bind nested element

From: KARR, DAVID (ATTSI) <"KARR,>
Date: Thu, 17 Jun 2010 07:55:20 -0700

> -----Original Message-----
> From: boraldo [mailto:boraldo_at_hotbox.ru]
> Sent: Wednesday, June 16, 2010 11:06 AM
> To: users_at_jaxb.dev.java.net
> Subject: How can I bind nested element
>
>
> There is my xml:
>
> <parent>
> <children>
> <child>1</child>
> <child>2</child>
> </children>
> </parent>
>
> I want to have the following Parent class:
>
> Parent{
> List<Child> children;
> }
>
> I don't want to have class for element 'children'.
> How should I map List<Child> children ?

Continuing with Erik's reply, I almost always declare collections like
this:

@XmlElementWrapper(name = "children")
@XmlElement(name = "child")
List<Child> children;

This will produce what you want.