📜  XmlRootElement 对象到字符串 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:32.683000             🧑  作者: Mango

代码示例1
JAXBContext context = JAXBContext.newInstance(Something.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
StringWriter out = new StringWriter();
marshaller.marshal(something, out);
String xml = out.toString();