users@jaxb.java.net

Help needed mapping a collection of Strings to an element with attribute

From: anbernas <andres.bernasconi_at_gmail.com>
Date: Thu, 27 Nov 2008 14:27:36 -0800 (PST)

Hi, I have the following XML (snippet)

...
<friendsList>
    <friend name="Fred"/>
    <friend name="Walter"/>
    ...
</friendsList>

And I want to map that structure to a List<String> (where each element in
the list should be "Fred", "Walter", etc.) I would like to try to avoid
creating and intermediate class for Friend that only contains a name. I am
also using annotations for this, so I would like to stick to that.

Is there any way to do it?

I tried the following but I don't understand where I am supposed to specify
the attribute of the element:
@XmlElementWrapper(name="friendsList")
@XmlElement(name="friend")
//_at_XmlAttribute(name="name") <-- both element and attribute are invalid
protected List<String> friendList;

Thank you very much for your time!
Regards
AB.
-- 
View this message in context: http://www.nabble.com/Help-needed-mapping-a-collection-of-Strings-to-an-element-with-attribute-tp20726382p20726382.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.