Java tutorial
//package com.java2s; import java.io.StringReader; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; public class Main { @SuppressWarnings("rawtypes") public static Object unmarshal(String xmlBody, Class objectClass) { try { JAXBContext context = JAXBContext.newInstance(objectClass); Unmarshaller u = context.createUnmarshaller(); return u.unmarshal(new StreamSource(new StringReader(xmlBody))); } catch (JAXBException e) { e.printStackTrace(); } return null; } }