JAXB: Best approach for marshalling to a string
843834Jan 13 2003 — edited Jan 14 2003Any opinions here for a servlet? I need to generate an xml document, validate it and then post it to a form element. I am using ByteArrayOutputStream and converting it to string, example:
// create a Marshaller and marshal to string
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ByteArrayOutputStream os = new ByteArrayOutputStream();
m.marshal(pcd, os);
xmlDoc = os.toString();