List of utility methods to do XML Node to String
String | stringifyNode(Node node) stringify Node try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); Source source = new DOMSource(node); ByteArrayOutputStream out = new ByteArrayOutputStream(); Result result = new StreamResult(out); transformer.transform(source, result); return out.toString(); } catch (TransformerConfigurationException e) { ... |
void | toHtml(StringBuffer html, Node node) _more_ switch (node.getNodeType()) { case Node.ELEMENT_NODE: { NodeList children = node.getChildNodes(); int numChildren = children.getLength(); html.append("<b>" + node.getNodeName().replace("_", " ") + "</b>"); html.append(": "); for (int i = 0; i < numChildren; i++) { Node child = children.item(i); ... |
String | toString(final Node node) Transform a DOM Node into an XML String. return toString(node, true);
|
String | toString(final Node node) Transform a DOM Node to String. TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); StringWriter writer = new StringWriter(); DOMSource source = new DOMSource(node); StreamResult result = new StreamResult(writer); transformer.transform(source, result); return writer.toString(); |
String | toString(final Node node) Returns the content of the given node as string final StringWriter out = new StringWriter(); write(node, new StreamResult(out)); return out.toString(); |
String | toString(final Node xml) to String try { final Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); final StreamResult result = new StreamResult(new StringWriter()); final DOMSource source = new DOMSource(xml); transformer.transform(source, result); return result.getWriter().toString(); ... |
String | toString(final short nodeType) to String return toClass(nodeType).getSimpleName();
|
String | toString(Node element) to String if (element == null) { return "null"; Source source = new DOMSource(element); StringWriter stringWriter = new StringWriter(); try (PrintWriter printWriter = new PrintWriter(stringWriter)) { Result result = new StreamResult(printWriter); Transformer transformer = TransformerFactory.newInstance().newTransformer(); ... |
String | toString(Node n) to String StringBuilder buf = new StringBuilder(); append(n, buf, 0); return buf.toString(); |
String | toString(Node n) to String TransformerHandler hd = newTransformerHandler(); Transformer serializer = hd.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); DOMSource source = new DOMSource(n); StringWriter w = new StringWriter(); StreamResult result = new StreamResult(w); serializer.transform(source, result); ... |