Java XML Document Serialize serialize(Document document, File targetFile)

Here you can find the source of serialize(Document document, File targetFile)

Description

serialize

License

Apache License

Declaration

public static void serialize(Document document, File targetFile) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Document;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.IOException;

public class Main {
    public static void serialize(Document document, File targetFile) throws IOException {
        try {//from   w  w  w.ja v  a 2  s.  c  o m
            Transformer t = TransformerFactory.newInstance().newTransformer();
            t.transform(new DOMSource(document), new StreamResult(targetFile));
        } catch (TransformerException e) {
            throw new IOException(e);
        }
    }
}

Related

  1. serialize(Document d, OutputStream out, URL transformerLocation, Map properties)
  2. serialize(Document doc)
  3. serialize(Document doc, Writer out)
  4. serialize(Document document, boolean prettyPrint)
  5. serialize(Document document, boolean prettyPrint)
  6. serialize(Document document, OutputStream ostream)
  7. serialize(Document document, OutputStream out)
  8. serialize(Document document, String fileName)
  9. serialize(Document document, Writer writer)