Here you can find the source of marshaller(Object o, Class> T)
public static String marshaller(Object o, Class<?> T)
//package com.java2s; //License from project: Apache License import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import java.io.*; public class Main { public static String marshaller(Object o, Class<?> T) { JAXBContext jc;/*from ww w. ja va2 s. c o m*/ Marshaller marshaller; StringWriter writer = new StringWriter(); try { jc = JAXBContext.newInstance(T); marshaller = jc.createMarshaller(); marshaller.marshal(o, writer); } catch (JAXBException e) { e.printStackTrace(); } return writer.toString(); } }