List of utility methods to do XML Node to String
String | xmlToString(Node doc) format xml with 2 space indentation. DOMSource domSource = new DOMSource(doc); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("encoding", "UTF-8"); StringWriter sw = new StringWriter(); ... |
String | xmlToString(Node node) convert an xml document to a string return xmlToString(node, "UTF-8"); |
String | xmlToString(Node node) xml To String Source source = new DOMSource(node); 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(); |
String | xmlToString(Node node) Purpose:Converts an XML Document to a String Object if (node == null) { return ""; Source source = new DOMSource(node); StringWriter stringWriter = new StringWriter(); Result result = new StreamResult(stringWriter); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); ... |
String | xmlToString(Node node) Convert XML Document to a String. try { Source source = new DOMSource(node); 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(); ... |