Eclipse XML formatter

This is way less than ideal, and I hope someone has a better solution, but it works:

Build a simple App using dom4j:

public static void main( final String[] args ) throws Exception {
    String text = FileUtils.readFileToString( new File( args[ 0 ] ) );
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setTrimText( false );

    XMLWriter writer = new XMLWriter( System.out, format );
    writer.write( DocumentHelper.parseText( text ) );
}

Create a runnable jar, (optional) batch script, and add as an external tool. Of course, you could try XMLTidy or some other command line XML formatter, but I have had better results with dom4j.


I like Notepad++ with the XML Tools plugin. It does XSLT, has an XPATH expression evaluator, and does DTD and schema validation. Toolchain download links:

  • Notepad++: http://sourceforge.net/project/downloading.php?group_id=95717&use_mirror=internap&filename=npp.5.0.Installer.exe&24657954
  • XML Plugins: http://sourceforge.net/project/downloading.php?group_id=189927&use_mirror=voxel&filename=xmltools_2.3.1_r639.zip&44936797
  • External Libraries: http://sourceforge.net/project/downloading.php?group_id=189927&use_mirror=internap&filename=ext_libs.zip&52274848

You can try this one if you like