code: public static String marshal(Object object) {
          if (object == null) {
              return null;
          }
  
          try {
              JAXBContext jaxbCtx = JAXBContext.newInstance(object.getClass());
  
              Marshaller marshaller = jaxbCtx.createMarshaller();
              marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
  
              StringWriter sw = new StringWriter();
              marshaller.marshal(object, sw);
  
              return sw.toString();
          } catch (Exception e) {
          }
  
          return null;
      }
docs: object -> xml
  
  @param object
  @param childClass