Skip to content

Instantly share code, notes, and snippets.

@edubriguenti
Last active May 27, 2020 13:34
Show Gist options
  • Save edubriguenti/24a45d358f3b74961face87fbdcb4042 to your computer and use it in GitHub Desktop.
Save edubriguenti/24a45d358f3b74961face87fbdcb4042 to your computer and use it in GitHub Desktop.
JAXB PARSE
public void toXml(UpdateRequest request) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(CreateResponse.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(request, sw);
String xmlContent = sw.toString();
System.out.println( xmlContent );
System.out.println( );
} catch (JAXBException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment