Here you can find the source of encodeBase64(Element elm)
public static String encodeBase64(Element elm) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.apache.commons.codec.binary.Base64; import org.w3c.dom.Element; public class Main { public static String encodeBase64(Element elm) throws Exception { ByteArrayOutputStream ostream = new ByteArrayOutputStream(); TransformerFactory transFac = TransformerFactory.newInstance(); Transformer trans = transFac.newTransformer(); trans.transform(new DOMSource(elm), new StreamResult(ostream)); return (new String(Base64.encodeBase64(ostream.toByteArray(), true))); }/* www . j a v a 2 s. c o m*/ }