License Public Domain
Lines 15
Keywords
DOM (4) xml (4)
Permissions
Owner: monkey103
Viewable by Everyone
Editable by All Siafoo Users

Writing a DOM Document to an XML File Atom Feed 0

# 's
 1// This method writes a DOM document to a file
2public static void writeXmlFile(Document doc, String filename) {
3 try {
4 // Prepare the DOM document for writing
5 Source source = new DOMSource(doc);
6
7 // Prepare the output file
8 File file = new File(filename);
9 Result result = new StreamResult(file);
10
11 // Write the DOM document to the file
12 Transformer xformer = TransformerFactory.newInstance().newTransformer();
13 xformer.transform(source, result);
14 } catch (TransformerConfigurationException e) {
15 } catch (TransformerException e) {
16 }
17}