@XmlRootElement(name = "person") public class Person { @XmlElement private String name; @XmlElement private int age; } JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); File xmlFile = new File("person.xml"); Person person = (Person) unmarshaller.unmarshal(xmlFile);


上一篇:
下一篇:
切换中文