List of utility methods to do XML Node Sibiling
Element | getNextSiblingElement(Node node) Returns the next sibling element of a Node. Node sibling = node.getNextSibling(); while ((sibling != null) && (sibling.getNodeType() != Node.ELEMENT_NODE)) { sibling = sibling.getNextSibling(); return (Element) sibling; |
Element | getNextSiblingElement(Node node) get Next Sibling Element Node n = node.getNextSibling(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getNextSibling(); return (Element) n; |
Element | getNextSiblingElement(Node node, String elemNames[]) Finds and returns the next sibling node with the given name. Node sibling = node.getNextSibling(); while (sibling != null) { if (sibling.getNodeType() == Node.ELEMENT_NODE) { for (int i = 0; i < elemNames.length; i++) { if (sibling.getNodeName().equals(elemNames[i])) { return (Element) sibling; sibling = sibling.getNextSibling(); return null; |
Node | GetNextSiblingElement(Node start) gets the sibling element of a node if (start == null) return start; Node node = start.getNextSibling(); if (node == null) return node; else if (node.getNodeType() != Node.ELEMENT_NODE) return GetNextSiblingElement(node); else ... |
Element | getNextSiblingElementByName(Node node, String name) Get the sibling Element of the supplied node that matches a given tag name. Node sibling = node.getNextSibling(); while (sibling != null) { if (sibling.getNodeType() == Node.ELEMENT_NODE && sibling.getLocalName() != null && sibling.getLocalName().equals(name)) { return (Element) sibling; sibling = sibling.getNextSibling(); return null; |
Element | getNextSiblingElementNS(Node node, String uri) get Next Sibling Element NS Node sibling = node.getNextSibling(); while (sibling != null) { if (sibling.getNodeType() == Node.ELEMENT_NODE) { String siblingURI = sibling.getNamespaceURI(); if (siblingURI != null && siblingURI.equals(uri)) { return (Element) sibling; sibling = sibling.getNextSibling(); return null; |
Element | getNextSiblingElementNS(Node node, String[][] elemNames) Finds and returns the next sibling node with the given qualified name. Node sibling = node.getNextSibling(); while (sibling != null) { if (sibling.getNodeType() == Node.ELEMENT_NODE) { for (int i = 0; i < elemNames.length; i++) { String uri = sibling.getNamespaceURI(); if (uri != null && uri.equals(elemNames[i][0]) && sibling.getLocalName().equals(elemNames[i][1])) { return (Element) sibling; ... |
Element | getNextVisibleSiblingElement(Node node) get Next Visible Sibling Element Node sibling = node.getNextSibling(); while (sibling != null) { if (sibling.getNodeType() == Node.ELEMENT_NODE && !isHidden(sibling)) { return (Element) sibling; sibling = sibling.getNextSibling(); return null; ... |
Node | getPreHomoSibling(Node aNode) get Pre Homo Sibling Node preSibling = aNode; while ((preSibling = preSibling.getPreviousSibling()) != null) { if (preSibling.getNodeName().equals(aNode.getNodeName())) { return preSibling; return null; |
Node | getPreviousSibling(Node node, short nodeType) get Previous Sibling Node parent = node.getParentNode(); if (parent == null) { System.out.println("Cannot get node [" + node + "] previous sibling. [" + node + "] has no parent."); return null; NodeList siblings = parent.getChildNodes(); int siblingCount = siblings.getLength(); int nodeIndex = 0; ... |