Java: How to Indent XML Generated by Transformer
问题 I'm using Java's built in XML transformer to take a DOM document and print out the resulting XML. The problem is that it isn't indenting the text at all despite having set the parameter "indent" explicitly. sample code public class TestXML { public static void main(String args[]) throws Exception { ByteArrayOutputStream s; Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Transformer t = TransformerFactory.newInstance().newTransformer(); Element a,b; a = d