Here you can find the source of toElement(String xml)
public static Element toElement(String xml)
//package com.java2s; import java.io.StringReader; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element toElement(String xml) { DOMResult dom = new DOMResult(); try {//w w w .java 2s . com TransformerFactory.newInstance().newTransformer().transform(new StreamSource(new StringReader(xml)), dom); } catch (Exception e) { } return ((Document) dom.getNode()).getDocumentElement(); } }