4
使用JAXB从XML字符串创建对象
如何使用下面的代码解组XML字符串并将其映射到下面的JAXB对象? 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 …