Java tutorial
//package com.java2s; import java.io.IOException; import java.io.StringReader; import javax.xml.transform.Result; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; public class Main { private static final TransformerFactory transFactory = TransformerFactory.newInstance(); public static void stringToResult(String source, Result result) throws IOException { try { Transformer trans = transFactory.newTransformer(); StringReader reader = new StringReader(source); trans.transform(new StreamSource(reader), result); } catch (TransformerException ex) { throw new IOException(ex); } } }