我该如何在Java中将org.jdom.Document转换为字符串?
new XMLOutputter().outputString(doc);
我自己找到了答案
XMLOutputter xmOut = new XMLOutputter();
System.out.println("----" + xmOut.outputString(doc));
你也可以使用 StringWriter 来实现这个功能
StringWriter writer = new StringWriter();
new XMLOutputter().output(doc, writer);
System.out.println(writer.toString());