XML Parsing

Outputting a Document

try 
{
  File newFile = new File("processedOrders.xml");
  FileWriter newFileStream = new FileWriter(newFile);
  newFileStream.write("<?xml version=\"1.0\"?>");
  newFileStream.write("<!DOCTYPE "+doc.getDoctype().getName()+" ");
  if (doc.getDoctype().getSystemId() != null) 
  {
    newFileStream.write(" SYSTEM ");
    newFileStream.write(doc.getDoctype().getSystemId());   
  }
  if (doc.getDoctype().getPublicId() != null) 
  {
    newFileStream.write(" PUBLIC ");
    newFileStream.write(doc.getDoctype().getPublicId());   
  }
  newFileStream.write(">");
         
  newFileStream.write(newRoot.toString());

  newFileStream.close();

} catch (IOException e) {
  System.out.println("Can't write new file.");   
}


José M. Vidal .

11 of 16