import java.io.IOException;
import java.io.StringWriter;
import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
public class DebugUtil {
public static String formatXML(Document doc) throws Exception {
StringWriter out=null;
try{
OutputFormat formate=OutputFormat.createPrettyPrint();
out=new StringWriter();
XMLWriter writer=new XMLWriter(out,formate);
writer.write(doc);
} catch (IOException e){
e.printStackTrace();
} finally{
out.close();
}
return out.toString();
}
}