XML Parsing
Document
to its XML
representation only requires calling toString()
on
it.normalize()
on it.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."); }
11 of 16