xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Oatham" <matthewoat...@hotmail.com>
Subject XML DOM to file using Transformer
Date Thu, 08 May 2003 13:05:28 GMT

I have managed to load an xml file to a DOM and manipulate the tree, however 
when I write the DOM to file using

  TransformerFactory tFactory = TransformerFactory.newInstance();
  Transformer transformer = tFactory.newTransformer();

  File testFile = new File("C:\\testFile.xml");

  DOMSource source = new DOMSource(document);
  StreamResult result = new StreamResult(testFile);
  transformer.transform(source, result);

The resulting file has no line breaks and the elements are all on on line! 
Is there any way I can preserve the formatting of the original xml file I 
used to create the DOM?



Hotmail messages direct to your mobile phone http://www.msn.co.uk/mobile

In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

View raw message