code: 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();
      }
docs: Transforms an annotated Object to a XML string using javax.xml.bind.Marshaller
  
  @param object to transform to a XML String
  @return a XML string representing the object
  @throws IOException if is not possible to parse the object