Indent XML in JEditorPane



I am trying to indent XML in a Java JEditorPane, so that this:



<mytag>
<tag1>
</tag1>
</mytag>


becomes:



<mytag>
<tag1>
</tag1>
</mytag>


I have tried constructing a DocumentBuilder object, and then transforming it with:



serializer.setOutputProperty(OutputKeys.INDENT, "yes")
serializer.setOutputProperty("{http://ift.tt/1fh1NGB", "4");


then set the text in the JEditorPane:



editorPane.setText(do serialization and transformation methods here)


It does not indent the XML however..


No comments:

Post a Comment