You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Martín Lahittette <ml...@telpin.com.ar> on 2001/01/16 02:49:17 UTC
Printing a DOM to file
Hi!
I'd like to write a DOM to a XML file. What should I use?
Thanks!!
Re: Printing a DOM to file
Posted by Sebastien Ponce <se...@cern.ch>.
You have to use XMLSerializer. Here is an example of code, using
OutputFormat to format the file :
OutputStream outputStream = new
FileOutputStream(your_file_as_File_object);
OutputFormat outputFormat = new OutputFormat(your_Dom_document);
outputFormat.setPreserveSpace(false);
outputFormat.setIndenting(true);
outputFormat.setLineWidth(0);
serializer = new XMLSerializer(outputStream, outputFormat);
serializer.serialize(your_Dom_document);
Sebastien
Mart�n Lahittette wrote:
> Hi!I'd like to write a DOM to a XML file. What should I use? Thanks!!