JAXB: unmarshalling xml with multiple names for the same element JAXB: unmarshalling xml with multiple names for the same element xml xml

JAXB: unmarshalling xml with multiple names for the same element


This corresponds to a choice structure. You could use an @XmlElements annotation for this use case:

@XmlElements({    @XmlElement(name="director", type=Employee.class),    @XmlElement(name="manager", type=Employee.class)})List<Employee> getEmployees() {    return employees;}

If you are starting from an XML schema the following will help: