0
Lets sagen, dass ich die folgende POJO Klasse, die ich jetztWie XmlRootElement Wrapper zu entfernen, während in JAXB Rangier
folgenden Code-Schnipsel mit Mir Marshalling eine Instanz von Klasse Employee mit JAXB@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
Class Employee {
private String firstName;
private String lastName;
private int age;
}
Marschall will
JAXBContext jc = JAXBContext.newInstance(Employee.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
OutputStream os = new FileOutputStream("C:\\employee.xml")
marshaller.marshal(employee, os);
Die erzeugte XML sieht aus wie
<Employee>
<firstName>Mark</firstName>
<lastName>Smith</lastName>
<age>30</age>
</Employee>
Frage: I don‘ t möchte das Standard-Mitarbeiter-Tag um Mitarbeiterdaten. heißt
Ich möchte Ausgabe wie folgt
<firstName>Mark</firstName>
<lastName>Smith</lastName>
<age>30</age>
Wie dies zu erreichen?