How to convert org.jdom.Document to String
Asked Answered
C

3

31

How do I to convert an org.jdom.Document to a String in Java?

Coterminous answered 3/12, 2010 at 8:25 Comment(0)
L
59
new XMLOutputter().outputString(doc);
Luciferin answered 3/12, 2010 at 8:29 Comment(0)
C
15

I got the answer myself

XMLOutputter xmOut = new XMLOutputter(); 
System.out.println("----" + xmOut.outputString(doc));
Coterminous answered 3/12, 2010 at 8:36 Comment(0)
M
0

You can as well do like this with StringWriter

    StringWriter writer = new StringWriter();
    new XMLOutputter().output(doc, writer);
    System.out.println(writer.toString());
Miran answered 22/12, 2022 at 12:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.