xmlrootelement object to string

Solutions on MaxInterview for xmlrootelement object to string by the best coders in the world

showing results for - "xmlrootelement object to string"
Chuck
28 Jul 2017
1JAXBContext context = JAXBContext.newInstance(Something.class);
2Marshaller marshaller = context.createMarshaller();
3marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
4StringWriter out = new StringWriter();
5marshaller.marshal(something, out);
6String xml = out.toString();
7