«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Archives
Today
Total
관리 메뉴

올해는 머신러닝이다.

Writing a DOM Document to an XML File 본문

Android/Tip&Tech

Writing a DOM Document to an XML File

행복한 수지아빠 2010. 11. 5. 15:30
Writing a DOM Document to an XML File
     
import java.io.File;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

public class Main {
  public static void main(String[] argvthrows Exception {
    Document doc = null;
    String filename = "name.xml";

    Source source = new DOMSource(doc);

    File file = new File(filename);
    Result result = new StreamResult(file);

    Transformer xformer = TransformerFactory.newInstance().newTransformer();
    xformer.transform(source, result);
  }
}

   
    
    
    
    
  
Related examples in the same category

1.  XML Document Writer
2.  XML Writer
3.  XMLWriter.java - serialize an XML document
4.  Convenience methods for writing XML
5.  Write DOM out
6.  write Xml DOM Node
7.  XMLWriter helper class
8.  DOM writer
9.  Write Xml (Node n, OutputStream os)
10.  Makes writing XML much much easier
11.  Use DOM L3 DOMBuilder, DOMBuilderFilter DOMWriter and other DOM L3 functionality to preparse, revalidate and safe document.