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
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