Java tutorial
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Node; import org.xml.sax.SAXException; public class Main { public static Node stringToNode(String string) { try { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return db.parse(new ByteArrayInputStream(string.getBytes())).getFirstChild(); } catch (SAXException ex) { throw new RuntimeException(ex); } catch (IOException ex) { throw new RuntimeException(ex); } catch (ParserConfigurationException ex) { throw new RuntimeException(ex); } } }