Here you can find the source of createTXT(Transformer xf, Node doc)
public static String createTXT(Transformer xf, Node doc) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Node; public class Main { public static String createTXT(Transformer xf, Node doc) throws Exception { OutputStream os = new ByteArrayOutputStream(); StreamResult res = new StreamResult(os); xf.transform(new DOMSource(doc), res); os.close();/*from ww w .ja v a 2 s. co m*/ return os.toString(); } }