Here you can find the source of xmlToObject(String xml, Class>... type)
public static Object xmlToObject(String xml, Class<?>... type)
//package com.java2s; //License from project: Apache License import java.io.StringReader; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public static Object xmlToObject(String xml, Class<?>... type) { try {/*from w ww. j a v a 2s . c o m*/ JAXBContext jaxbContext = JAXBContext.newInstance(type); StringReader stringReader = new StringReader(xml); Unmarshaller jaxbUnmarshaller = jaxbContext .createUnmarshaller(); return jaxbUnmarshaller.unmarshal(stringReader); } catch (JAXBException e) { e.printStackTrace(); } return null; } }