List of utility methods to do XML Document to String
byte[] | writeToBytes(Document document) DOCUMENT ME! byte[] ret = null; TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setAttribute("indent-number", new Integer(4)); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(document); ByteArrayOutputStream bos = new ByteArrayOutputStream(); StreamResult result = new StreamResult(bos); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); ... |
byte[] | writeXML(Document d) write XML ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeXML(d, baos); baos.close(); return baos.toByteArray(); |
String | writeXmlToString(Document xmlDoc) writeXmlToString - write the given XML document to a string. TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty("omit-xml-declaration", "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(xmlDoc), new StreamResult(writer)); String output = writer.getBuffer().toString(); return output; |
String | xmlDocToString(Document doc) xml Doc To String return elementToString(doc.getDocumentElement());
|
String | xmlDocToString(Document doc) Place the contents of an XML Document into a string object. String output = null; TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer; try { transformer = transformerFactory.newTransformer(); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); output = writer.getBuffer().toString().replaceAll("\n|\r", ""); ... |
Element | xmlDocumentDecode(final String xmlURI) Xml document decode. return XML_BUILDER.get().parse(xmlURI).getDocumentElement();
|
String | xmlDocumentToString(Document doc) xml Document To String try { StringWriter sw = new StringWriter(); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); ... |
String | xmlDocumentToString(Document doc) xml Document To String if (doc == null) { return ""; String xmlDocString = ""; try { StringWriter writer = new StringWriter(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); ... |
String | xmlDocumentToString(Document doc) xml Document To String try { DOMSource domSource = new DOMSource(doc); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); return writer.toString(); ... |
String | xmlDocumentToString(Document document) Write a DOM document to a string try { Source source = new DOMSource(document); StringWriter stringWriter = new StringWriter(); Result result = new StreamResult(stringWriter); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); transformer.transform(source, result); return stringWriter.getBuffer().toString(); ... |