@XmlType
class FriendsList {
@XmlElement
List<String> friend;
}
That's all you need.
-WL
On Thu, Nov 27, 2008 at 11:27 PM, anbernas <andres.bernasconi_at_gmail.com>wrote:
>
> 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.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>