Ugly XML files, missing line breaks.
Hello everyone,
using org.w3c.dom and the following output methodpublicstaticvoid writeDocumentNode(Node node, File file)
throws TransformerException{
// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
try{
Transformer transformer = tFactory.newTransformer();
DOMSource source =new DOMSource(node);
StreamResult result =new StreamResult(file);
transformer.transform(source, result);
}catch (TransformerConfigurationException e){
e.printStackTrace();
}
}
the resulting XML files are not very readable. They look like this:
<?xml ..?><a><b/><c/></a>
but I want them to look like this:
<?xml ...?>
<a>
<b/>
<c>
</a>
How can this be accomplished without having to manually insert "\n" text nodes? I've googled for about half an hour, but to no avail.
(I cannot use external libraries)
Greetings,
Dan

