dom4j格式化xml文件
dom4j格式xml并输出为*.xml文件
public static String formatXml(String str) throws DocumentException, IOException {SAXReader reader=new SAXReader();StringReader in=new StringReader(str);Document doc=reader.read(in);OutputFormat formater=OutputFormat.createPrettyPrint();formater.setEncoding("UTF-8");StringWriter out=new StringWriter();XMLWriter writer=new XMLWriter(out,formater);writer.write(doc);writer.close();return out.toString();}