Java tutorial
//package com.java2s; import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Element; public class Main { private static Transformer transformer; public static String trans(Element ele) { StringWriter writer = new StringWriter(); try { transformer.transform(new DOMSource(ele), new StreamResult(writer)); } catch (TransformerException e) { e.printStackTrace(); } return writer.toString(); } }