Java tutorial
//package com.java2s; //License from project: Apache License import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import java.io.*; public class Main { @SuppressWarnings("unchecked") public static <T> T unmarshaller(String xml, Class<?> T) { JAXBContext jc; Unmarshaller unmarshaller; Object o = null; try { jc = JAXBContext.newInstance(T); unmarshaller = jc.createUnmarshaller(); o = unmarshaller.unmarshal(new StreamSource(new StringReader(xml))); } catch (JAXBException e) { e.printStackTrace(); } return (T) o; } }