Java tutorial
//package com.java2s; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.*; public class Main { @SuppressWarnings("unchecked") public static Object convertXmlStringToObject(String xml, Class clazz) { Object object = null; try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); StringReader xmlReader = new StringReader(xml); object = unmarshaller.unmarshal(xmlReader); } catch (JAXBException e) { e.printStackTrace(); } return object; } }