Here you can find the source of convertXmlToObj(Class clazz, String xmlStr)
public static Object convertXmlToObj(Class clazz, String xmlStr)
//package com.java2s; 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 convertXmlToObj(Class clazz, String xmlStr) { try {/* www . jav a 2 s . c om*/ JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); return unmarshaller.unmarshal(new StringReader(xmlStr)); } catch (JAXBException e) { e.printStackTrace(); } return null; } }