Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static synchronized void appedIndent(Element e, int indent) { Document doc = e.getOwnerDocument(); if (indent == 0) { e.appendChild(doc.createTextNode("\n")); } for (int i = 0; i < indent; i++) { if (i == 0) { e.appendChild(doc.createTextNode("\n\t")); } else { e.appendChild(doc.createTextNode("\t")); } } } }