Java tutorial
//package com.java2s; import java.io.ByteArrayInputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public static <T> Object fromXml(String xmlStr, Class<T> pojoClass) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(pojoClass); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Object object = unmarshaller.unmarshal(new ByteArrayInputStream(xmlStr.getBytes())); return object; } }