Here you can find the source of elementToStream(Element element, OutputStream out)
Parameter | Description |
---|---|
element | a parameter |
out | a parameter |
Parameter | Description |
---|---|
TransformerConfigurationException | an exception |
TransformerException | an exception |
public static void elementToStream(Element element, OutputStream out) throws TransformerConfigurationException, TransformerException
//package com.java2s; //License from project: Apache License import java.io.OutputStream; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Element; public class Main { /**// w w w . ja v a2s.co m * Write the content of a DOM element to the provided outputstream * * @param element * @param out * @throws TransformerConfigurationException * @throws TransformerException */ public static void elementToStream(Element element, OutputStream out) throws TransformerConfigurationException, TransformerException { DOMSource source = new DOMSource(element); StreamResult result = new StreamResult(out); TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.transform(source, result); } }