Java XML Document to Stream writeXML(OutputStream os, Document doc)

Here you can find the source of writeXML(OutputStream os, Document doc)

Description

Writes the specified DOM to the given output stream.

License

Open Source License

Declaration

public static void writeXML(OutputStream os, Document doc) throws TransformerException 

Method Source Code


//package com.java2s;
import java.io.*;

import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;

import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.*;

public class Main {
    /** Factory for generating transformers. */
    public static final TransformerFactory TRANS_FACT = TransformerFactory.newInstance();

    /** Writes the specified DOM to the given output stream. */
    public static void writeXML(OutputStream os, Document doc) throws TransformerException {
        Transformer idTransform = TRANS_FACT.newTransformer();
        Source input = new DOMSource(doc);
        Result output = new StreamResult(os);
        idTransform.transform(input, output);
    }/*from w w  w  .j  a  va  2  s. c o m*/
}

Related

  1. writeXML(Document doc, OutputStream os)
  2. writeXML(Document doc, OutputStream out)
  3. writeXml(Document doc, OutputStream outputStream)
  4. writeXML(Document document, OutputStream os)
  5. writeXML(final Document doc, final OutputStream out)
  6. writeXml(OutputStream outputEntry, Document document)
  7. writeXmlDocumentToStream(Document document, OutputStream stream)