<employee> <id>1</id> <name>John Doe</name> <age>30</age> </employee> public class Employee { private int id; private String name; private int age; } JAXBContext context = JAXBContext.newInstance(Employee.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Employee employee = (Employee) unmarshaller.unmarshal(new File("employee.xml")); System.out.println(employee.getId()); System.out.println(employee.getName()); System.out.println(employee.getAge());


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