Java XML Element to String elementToStream(Element element, OutputStream out)

Here you can find the source of elementToStream(Element element, OutputStream out)

Description

element To Stream

License

Apache License

Declaration

public static void elementToStream(Element element, OutputStream out)
            throws TransformerException 

Method Source Code

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

import org.w3c.dom.Element;

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.OutputStream;

public class Main {
    public static void elementToStream(Element element, OutputStream out)
            throws TransformerException {
        DOMSource source = new DOMSource(element);
        StreamResult result = new StreamResult(out);
        TransformerFactory transFactory = TransformerFactory.newInstance();
        Transformer transformer = transFactory.newTransformer();
        transformer.transform(source, result);
    }/*from ww w.  java 2 s. c  o m*/
}

Related

  1. elementToStream(Element element, OutputStream out)
  2. elementToString(Element e)
  3. elementToString(Element el)
  4. elementToString(Element element)