public static String ObjectToXml ( Object object ) throws JAXBException { JAXBContext jaxbContext = JAXBContext . newInstance ( object . getClass ( ) ) ; Marshaller marshaller = jaxbContext . createMarshaller ( ) ; StringWriter sw = new StringWriter ( ) ; marshaller . marshal ( object , sw ) ; return sw . toString ( ) ; }
Transforms an annotated Object to a XML string using javax . xml . bind . Marshaller