List of utility methods to do XML Node Print
void | printNode(Node node, StringWriter sw) Write a node to the current output buffer if (node.getNodeType() == Node.TEXT_NODE) { String content = node.getTextContent(); if (content.contains("&")) content = content.replace("&", "&"); sw.write(content); } else if (node.getNodeType() == Node.ELEMENT_NODE) { printElementStart((Element) node, sw); printElementBody((Element) node, sw); ... |
void | printNodeBasics(Node node) Prints a given Node For debugging purpose only if (node == null) System.out.println(" Null node"); return; System.out.println(" Node[Namespace URI=" + node.getNamespaceURI() + " localname=" + node.getLocalName() + " name=" + node.getNodeName() + " type=" + ... |
void | printNodeIterator(NodeIterator iterator) print Node Iterator Node n; while ((n = iterator.nextNode()) != null) { System.out.println("Node:" + n.getNodeValue()); |
void | printNodes(Node node, int level) Method to print nodes of the DOM level++; System.out.println(node); for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) { printNodes(child, level); return; |
void | printNodeType(Node node, int ident) prints the type of the input node System.out.print("Node: " + node.getNodeName() + " "); switch (node.getNodeType()) { case Node.DOCUMENT_NODE: System.out.println("Document Node"); break; case Node.ELEMENT_NODE: System.out.println("Element Node"); for (int j = 0; j < 2 * ident; j++) ... |
void | printToTerminal(Node n, String indent, boolean descend) print To Terminal if (n != null) { System.out.println(indent + "Name: " + n.getNodeName()); System.out.println(indent + "NS : " + n.getNamespaceURI()); System.out.println(indent + "txt : " + n.getTextContent()); System.out.println(indent + "Type: " + n.getNodeType()); System.out.println(indent + "Val : [" + n.getNodeValue() + "]"); if (n.hasAttributes()) printAttributesCompact(n.getAttributes(), indent, descend); ... |
void | printTree(Node node, int ident) prints the document tree if (node == null) return; NodeList children; System.out.print("Node: " + node.getNodeName() + " "); switch (node.getNodeType()) { case Node.DOCUMENT_NODE: System.out.println("Document Node"); break; ... |
void | printTree(Node root, int level) print a text representation of the dom hierarchy. NodeList l = root.getChildNodes(); for (int i = 0; i < level; i++) System.out.print(" "); NamedNodeMap attribMap = root.getAttributes(); String attribs = getAttributeList(attribMap); System.out.println("Node: <" + root.getNodeName() + "> " + attribs); for (int i = 0; i < l.getLength(); i++) { printTree(l.item(i), level + 1); ... |