List of utility methods to do XML Node Tree
void | dump(final Node node) Recursively walks the DOM tree starting at the given Node printing the gory details of its construction to System.out .
doDump(System.out, node, 0); |
void | dump(Node node) dump System.out.println("Node: " + node.getNodeName()); NamedNodeMap nnm = node.getAttributes(); if (nnm != null) { for (int i = 0; i < nnm.getLength(); i++) { Node n = nnm.item(i); System.out.println(" " + n.getNodeName() + ":" + n.getNodeValue()); |
String | dumpTree(Node node) dump Tree StringBuilder sb = new StringBuilder(); Stack<Node> stack = new Stack<Node>(); int level = 0; while (node != null || !stack.isEmpty()) { if (node == null) { do { node = stack.pop(); --level; ... |
Node | moveSubTree(Node from, Node to, Node context) Copies all child nodes from the first Element tree into the second Element tree inserted before the given context node. NodeList children = from.getChildNodes(); Node[] asArray = convertToArray(children); Document fromDoc = from.getOwnerDocument(); Document toDoc = to.getOwnerDocument(); for (int n = 0; n < asArray.length; ++n) { from.removeChild(asArray[n]); if (fromDoc != toDoc) asArray[n] = toDoc.importNode(asArray[n], true); ... |