List of utility methods to do XML Node Next
Node | getNext(final Node current, final boolean sameName) get Next String name = null; if (sameName) { name = current.getNodeName(); int type = current.getNodeType(); return getNext(current, name, type); |
Node | getNext(Node current) Get the next sibling with the same name and type String name = current.getNodeName(); int type = current.getNodeType(); return getNext(current, name, type); |
Node | getNext(Node current, String name, int type) Return the next sibling with a given name and type Node first = current.getNextSibling(); if (first == null) return null; for (Node node = first; node != null; node = node.getNextSibling()) { if (type >= 0 && node.getNodeType() != type) continue; if (name == null) return node; ... |
Node | getNext(Node node) Get the next node in a depth first preorder traversal. if (node == null) return null; if (node.getFirstChild() != null) return node.getFirstChild(); for (; node != null; node = node.getParentNode()) { if (node.getNextSibling() != null) return node.getNextSibling(); return null; |
String | getNextComment(Node element) Gets the next comment. while (element.getNextSibling() != null) { Node prev = element.getNextSibling(); if (prev.getNodeType() == Node.COMMENT_NODE) { return prev.getTextContent(); } else if (prev.getNodeType() == Node.TEXT_NODE) { return getNextComment(prev); } else if (prev.getNodeType() == Node.ELEMENT_NODE) { return null; ... |
String | getNextComment(Node element) get Next Comment while (element.getNextSibling() != null) { Node prev = element.getNextSibling(); if (prev.getNodeType() == Node.COMMENT_NODE) { return prev.getTextContent(); } else if (prev.getNodeType() == Node.TEXT_NODE) { return getNextComment(prev); } else if (prev.getNodeType() == Node.ELEMENT_NODE) { return null; ... |
Element | getNextElement(Node el) get Next Element Node node = el; while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getNextSibling(); return (Element) node; |
Element | getNextElement(Node node) Get the next right sibling that is an element. Element found = null; if (node != null) { for (Node next = node.getNextSibling(); next != null && found == null; next = next.getNextSibling()) { if (next.getNodeType() == Node.ELEMENT_NODE) { found = (Element) next; return found; |
Element | getNextElement(Node node) get Next Element node = node.getNextSibling(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { return (Element) node; node = node.getNextSibling(); return null; ... |
Node | getNextElement(Node node) Get a sibling XML element of a given node. Node child = node.getNextSibling(); if (child == null) return null; if (child.getNodeType() == Node.ELEMENT_NODE) return child; while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) return child; ... |