Here you can find the source of createMarshaller(Object object)
private static Marshaller createMarshaller(Object object)
//package com.java2s; //License from project: Open Source License import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Main { private static Marshaller createMarshaller(Object object) { JAXBContext context;// w w w .j av a2 s. c o m Marshaller marshaller = null; try { context = JAXBContext.newInstance(object.getClass()); marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } return marshaller; } }