views:

38

answers:

1

I have something like

@XmlElementWrapper(name="Mylist")
List<Items> myItems = new ArrayList<Items>()

and that comes out like

<Mylist>
   <myItems>item 1</myItems>
   <myItems>item 2</myItems>
   <myItems>item 3</myItems>
</Mylist>

Is it possible to make this come out more like

<Mylist>
   <myItems>item 1, item 2, item 3</myItems>
</Mylist>

Since the data I am after is all just textual anyway?

A: 

You can use @XmlList to make it a space separated value.

For a comma separated list you will need to use an XmlAdapter. For more information on XmlAdapter see:

Blaise Doughan
Are you saying in the new adapter class then I would simply cat all the items in the list together, and use @XmlValue on the newly created string?
Derek
Yes, then going the other direction you could tokenize the String on the ',' character.
Blaise Doughan