[Jaxb]

S

Stefanie Ertheld

Hi,

I've got an xml document like this:

<xml version="1.0 encoding="UTF-8">
<employees id="1" room="123">

<employee>
<firstname>Peter</firstname>
<lastname>Meyer</lastname>
</employee>
<employee>
<firstname>Betty</firstname>
<lastname>Boo</lastname>
</employee>

</employees>

How can that be mapped to jaxb annotations?
I've tried all sorts of things, like:

@XmlRootElement(name = "employees")
@XmlAccessorType(XmlAccessType.FIELD)
public class Employees {

@XmlAttribute(name = "id")
private String id;

@XmlAttribute(name = "room")
private String room;

@XmlElement(name = "employee")
@XmlElementWrapper(name = "employees")
private Employee[] employees;
[...]

However, this doesn't work. There is a problem with the employees
Element.
On Google I found various examples of the type:

<company>
<employees id="1" room="123">

<employee>
<firstname>Peter</firstname>
<lastname>Meyer</lastname>
</employee>
<employee>
<firstname>Betty</firstname>
<lastname>Boo</lastname>
</employee>
<employees>

</company>

This works easily - however when the document
root element is also at the same time a list,
I can't get it to work.
Any ideas?

Thanks in advance,

Stefanie
 
S

Stefan Ram

Stefanie Ertheld said:
Subject: [Jaxb]

Brackets usually are not used around the actual subject of a
Usenet post.

We might see some funny effects, when someone from certain
web gateways responds to a post, where all of the subject is
contained in brackets. (Well, in fact, the OP was posted via
such a gateway.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top