介绍
JAXB(Java Architecture for XML Binding)是业界的一个XML绑定JavaBean的标准。它可以根据xml文档生成Java类,也可以反过来根据Java类生成xml文档。
入门
JAXBContext context = JAXBContext.newInstance(Autotest.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
autotest = (Autotest) unmarshaller.unmarshal(new ByteArrayInputStream(doc.asXML().getBytes()));
ByteArrayOutputStream dataSourceByteOut = new ByteArrayOutputStream();
context.createMarshaller().marshal(dataSources, dataSourceByteOut);
[/codesyntax]