List of utility methods to do XML Document to Stream
void | writeXML(final Document doc, final OutputStream out) write XML final TransformerFactory factory = TransformerFactory.newInstance(); factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); final Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); ... |
void | writeXML(OutputStream os, Document doc) Writes the specified DOM to the given output stream. Transformer idTransform = TRANS_FACT.newTransformer(); Source input = new DOMSource(doc); Result output = new StreamResult(os); idTransform.transform(input, output); |
void | writeXml(OutputStream outputEntry, Document document) write Xml writeXml(createIndentingTransformer(), outputEntry, document); |
void | writeXmlDocumentToStream(Document document, OutputStream stream) Write a DOM document to an OutputStream Source source = new DOMSource(document); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); StreamResult result = new StreamResult(stream); transformer.transform(source, result); stream.flush(); |