java如何将xml转换成对象,请给出代码示例
时间: 2023-03-15 21:16:19 浏览: 131
Java可以使用JAXB来实现XML到对象的转换。以下是一个示例代码:JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Customer customer = (Customer) jaxbUnmarshaller.unmarshal(new File("C:\\file.xml"));
阅读全文