You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Matthew Oatham <ma...@hotmail.com> on 2003/05/08 15:05:28 UTC

XML DOM to file using Transformer

Hi,

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?

Thanks

Matt

_________________________________________________________________
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