javaxmlformattingstaxwoodstox

StAX XML formatting in Java


Is it possible using StAX (specifically woodstox) to format the output xml with newlines and tabs, i.e. in the form:

<element1>
  <element2>
   someData
  </element2>
</element1>

instead of:

<element1><element2>someData</element2></element1>

If this is not possible in woodstox, is there any other lightweight libs that can do this?


Solution

  • Via the JDK: transformer.setOutputProperty(OutputKeys.INDENT, "yes");.