Here you can find the source of serializeElement(Element element)
public static String serializeElement(Element element) throws TransformerFactoryConfigurationError, TransformerException
//package com.java2s; import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactoryConfigurationError; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Element; public class Main { public static String serializeElement(Element element) throws TransformerFactoryConfigurationError, TransformerException { String serializedElement = null; if (element != null) { StringWriter output = new StringWriter(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(element), new StreamResult(output)); serializedElement = output.toString(); }// www. jav a 2 s .c om return serializedElement; } }