Java tutorial
//package com.java2s; import java.io.StringReader; import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; public class Main { public static Object xml2Bean(String xml, Object obj) throws Exception { JAXBContext context = JAXBContext.newInstance(obj.getClass()); Unmarshaller um = context.createUnmarshaller(); StringReader sr = new StringReader(xml); return um.unmarshal(sr); } }