Jak mogę użyć poniższego kodu, aby usunąć ciąg XML z kodu XML i zamapować go na obiekt JAXB poniżej?
JAXBContext jaxbContext = JAXBContext.newInstance(Person.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Person person = (Person) unmarshaller.unmarshal("xml string here");
@XmlRootElement(name = "Person")
public class Person {
@XmlElement(name = "First-Name")
String firstName;
@XmlElement(name = "Last-Name")
String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}