Java XML Document to String write2xml(Document document)

Here you can find the source of write2xml(Document document)

Description

writexml

License

Apache License

Declaration

public static void write2xml(Document document) 

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.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

public class Main {

    public static void write2xml(Document document) {
        try {/*from w  w w  . j  a va2s  .c  om*/
            Transformer ts = TransformerFactory.newInstance().newTransformer();
            ts.transform(new DOMSource(document), new StreamResult("xml/exam.xml"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. toXmlString(Document document)
  2. write(Document doc)
  3. write(Document doc, Result result)
  4. write(String filename, Document document, boolean addDocType)
  5. write2Xml(Document document)
  6. write_DOM_into_an_HTML_file(Document doc, String htmlFile, String xslFile)
  7. writeDocument(Document doc, boolean omitXmlDeclaration)
  8. writeDocument(Document document)
  9. writeDocumentToStreamResult(Document document, StreamResult outputTarget)