Java tutorial
import java.io.StringReader; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; public class Main { public static void main(String[] args) throws Exception { String xmlString = "<message>HELLO!</message> "; JAXBContext jc = JAXBContext.newInstance(String.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); StreamSource xmlSource = new StreamSource(new StringReader(xmlString)); JAXBElement<String> je = unmarshaller.unmarshal(xmlSource, String.class); System.out.println(je.getValue()); } }