List of utility methods to do XML Node to String
String | toString(Node node, boolean formatted) to String ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeNode(node, baos, formatted); return (baos.toString()); |
String | toString(Node node, int level, boolean indent) to String StringBuilder nodeBuilder = new StringBuilder(); switch (node.getNodeType()) { case Node.TEXT_NODE: if (indent) { nodeBuilder.append(setIndent(level)); nodeBuilder.append(node.getNodeValue()); if (indent) { ... |
String | toString(Node node, Map Converts an XML node to a string. try { StringWriter writer = new StringWriter(); toWriter(node, writer, outputProperties); return writer.toString(); } catch (TransformerException e) { throw new RuntimeException(e); |
String | toString(Node node, Map Converts an XML node to a string. try { StringWriter writer = new StringWriter(); toWriter(node, writer, outputProperties); return writer.toString(); } catch (TransformerException e) { throw new RuntimeException(e); |
void | toString(Node node, StringBuilder sb) to String sb.append(node.getClass().getSimpleName()); if (node instanceof Element) { Element el = (Element) node; sb.append(":"); sb.append(el.getNodeName()); sb.append(" "); attrToString(el, sb); |
String | toString(Node xml) Transform this Node into a String representation. short type = xml.getNodeType(); if (type == Node.TEXT_NODE) return xml.getNodeValue(); StringWriter buffer = new StringWriter(); try { TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); ... |
String | toString(NodeList nodes) to String try { StringWriter stw = new StringWriter(); Transformer serializer = TransformerFactory.newInstance().newTransformer(); for (int i = 0; i < nodes.getLength(); i++) { Node item = nodes.item(i); switch (item.getNodeType()) { case Node.TEXT_NODE: stw.append(item.getTextContent()); ... |
String | toStringE(Node element) to String E try { 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); ... |
String | toText(Node node) This class converts a DOM representation node to text. String ret = null; try { ByteArrayOutputStream xmlstr = new ByteArrayOutputStream(); DOMSource source = new DOMSource(node); StreamResult result = new StreamResult(xmlstr); Transformer trans = TransformerFactory.newInstance().newTransformer(); trans.transform(source, result); xmlstr.close(); ... |
String | toText(Node node) to Text try { DOMSource source = new DOMSource(node); Transformer identity = TransformerFactory.newInstance().newTransformer(); identity.setOutputProperty(OutputKeys.INDENT, "no"); identity.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Result result = new StreamResult(baos); identity.transform(source, result); ... |