List of utility methods to do XML Document to File
void | writeXmlFile(Document doc, File file, boolean indent, String encoding) write Xml File Source source = new DOMSource(doc); Result result = new StreamResult(file); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(OutputKeys.ENCODING, encoding); if (indent) { xformer.setOutputProperty(OutputKeys.INDENT, "yes"); xformer.transform(source, result); ... |
void | writeXmlFile(Document doc, String filename) Write DOM to a file writeXmlFile(doc, filename, "ISO-8859-1", "no"); |
void | writeXmlFile(Document doc, String filename) write Xml File Source source = new DOMSource(doc); File file = new File(filename); Result result = new StreamResult(file); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); |
void | writeXmlFile(Document doc, String filename) Writes and org.w3c.dom.Document to a file Source source = new DOMSource(doc); File file = new File(filename); Result result = new StreamResult(file); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); |
void | writeXMLFile(Document document, Writer writer) write XML File DOMImplementation implementation = document.getImplementation(); if (implementation.hasFeature(LS_FEATURE_KEY, LS_FEATURE_VERSION) && implementation.hasFeature(CORE_FEATURE_KEY, CORE_FEATURE_VERSION)) { DOMImplementationLS implementationLS = (DOMImplementationLS) implementation.getFeature(LS_FEATURE_KEY, LS_FEATURE_VERSION); LSSerializer serializer = implementationLS.createLSSerializer(); DOMConfiguration configuration = serializer.getDomConfig(); configuration.setParameter("well-formed", Boolean.TRUE); ... |
long | writeXmlFile(File file, Document document) write Xml File DOMSource doms = new DOMSource(document); StreamResult result = new StreamResult(file); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); Properties properties = transformer.getOutputProperties(); properties.setProperty(OutputKeys.ENCODING, "utf-8"); properties.setProperty(OutputKeys.METHOD, "xml"); properties.setProperty(OutputKeys.INDENT, "yes"); ... |
boolean | writeXmlFile(String fileName, Document document) Writes XML Document into an xml file. File file = new File(fileName); TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.transform(new DOMSource(document), new StreamResult(file)); ... |
void | WriteXMLFile2(Document doc, String strFilePath) Write the Document in memory out to a standard XML file.
File file = new File(strFilePath); try { file.createNewFile(); if (!file.canWrite()) { throw new Exception("FileNotWriteable"); } catch (IOException ioe) { throw ioe; ... |
void | writeXmlToStream(Document doc, OutputStream stream) write Xml To Stream Result result = new StreamResult(stream);
transform(doc, result);
|
void | writeXMLtoStream(Object osw, Document doc) writes the given XML Document to the given Writer. try { TransformerFactory _transformerFactory = TransformerFactory.newInstance(); try { _transformerFactory.setAttribute("indent-number", new Integer(4)); } catch (IllegalArgumentException ex) { Transformer _transformer = _transformerFactory.newTransformer(); _transformer.setOutputProperty(OutputKeys.INDENT, "yes"); ... |