I\'m writing an XML file with the following code:
Source source = new DOMSource(rootElement); Result result = new StreamResult(xmlFile); Transformer transformer
You may have to specify the amount of spaces to indent as well:
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");