默认的输出是不格式化的。
你需要使用下面的代码将输出格式化:
[code]Format xmlFormat = Format.getPrettyFormat(); xmlFormat.setEncoding(“UTF-8”);// 设置xml文件的字符为UTF-8,解决中文问题
String responseXML = new XMLOutputter(xmlFormat).outputString(document);[/code]
格式化后输出的内容为: