List of utility methods to do XML Node Sibiling
boolean | containsSiblings(org.w3c.dom.Node node) contains Siblings NodeList childNodes = node.getChildNodes(); if (childNodes != null) if (childNodes.getLength() > 1) return true; else if (containsSiblings(childNodes.item(0))) return true; return false; |
Element | getFirstElementSibling(Node node) Returns the first subsequent sibling of a given node which is an Element. return (node == null || node instanceof Element) ? (Element) node : getFirstElementSibling(node.getNextSibling()); |
Element | getFirstSiblingElmt(Node aNode) get First Sibling Elmt if (aNode == null) { return null; Node wNode = aNode.getNextSibling(); while (wNode != null && wNode.getNodeType() != Node.ELEMENT_NODE) { wNode = wNode.getNextSibling(); return (Element) wNode; ... |
Node | getFirstSiblingNamed(Node node, String name) Returns the first sibling of node , or node itself, which has the given name.
while (node != null && !node.getNodeName().equals(name)) { node = node.getNextSibling(); return node; |
int | getLocHomoSibling(Node aNode) aims at finding the location of the current node of its kind. int countOfBranch = 0; Node preSibling = aNode; while ((preSibling = preSibling.getPreviousSibling()) != null) { if (preSibling.getNodeName().equals(aNode.getNodeName())) { countOfBranch++; return countOfBranch; ... |
Element | getNextElementSibling(Node node) Returns the next sibling element of the given node. node = node.getNextSibling(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { return (Element) node; node = node.getNextSibling(); return null; ... |
Node | getNextElementSibling(Node node) get Next Element Sibling node = node.getNextSibling(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getNextSibling(); return node; |
Node | getNextElementSibling(Node node) get Next Element Sibling node = node.getNextSibling(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getNextSibling(); return node; |
Node | getNextHomoSibling(Node aNode) this function is different from above one. Node nextSibling = aNode; while ((nextSibling = nextSibling.getNextSibling()) != null) { if (nextSibling.getNodeName().equals(aNode.getNodeName())) { return nextSibling; return null; |
Node | getNextNamedSibling(Node node, String nodeName) get Next Named Sibling Node nextSibling = node.getNextSibling(); while (nextSibling != null && !nextSibling.getNodeName().equals(nodeName)) { nextSibling = nextSibling.getNextSibling(); return nextSibling; |