List of utility methods to do XML Element Sibling
Element | getNextSiblingElement(Node node) Returns the next sibling element of the specified node, or null if there is no such element. Node sibling = node.getNextSibling(); while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE) { sibling = sibling.getNextSibling(); return (Element) sibling; |
Element | getNextSiblingElementByTagName(Element e, String name) Get the next sibling of e which is an element and has tag name name , or null if there is no such element.
Node n = e; if (n == null) return null; while ((n = n.getNextSibling()) != null) { if (n.getNodeType() == Node.ELEMENT_NODE && ((Element) n).getTagName().equals(name)) return (Element) n; return null; ... |
Element | getNextSiblingElementWithName(Element elem, String name) get Next Sibling Element With Name if (elem == null) { return null; for (Element e = getNextSiblingElement(elem); e != null; e = getNextSiblingElement(e)) { if (e.getTagName().equals(name)) { return (Element) e; return null; |
Element[] | getPrecedingSiblings(Element element, String namespaceUri) Returns all preceding sibling elements of an element that belong to a certain namespace. return getPrecedingSiblings(element, namespaceUri, "*"); |
Element | getPreviousSiblingElement(Element elem) get Previous Sibling Element if (elem == null) { return null; for (Node n = elem.getPreviousSibling(); n != null; n = n.getPreviousSibling()) { if (n.getNodeType() == Node.ELEMENT_NODE) { return (Element) n; return null; |
Element | getPreviousSiblingElementByTagName(Element e, String name) Get the previous sibling of e which is an element and has tag name name , or null if there is no such element.
Node n = e; if (n == null) return null; while ((n = n.getPreviousSibling()) != null) { if (n.getNodeType() == Node.ELEMENT_NODE && ((Element) n).getTagName().equals(name)) return (Element) n; return null; ... |
Element | getPrevSibling(Element e) get Prev Sibling Node n = e.getPreviousSibling(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return (Element) n; |
Element | getPrevSibling(Element element) Get the previous sibling element of the specified element, null if it has no previous other siblings. if (element == null) return null; Node node = element.getPreviousSibling(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) return (Element) node; node = node.getPreviousSibling(); return null; |
Element | getSiblingElement(Element e, String name) Gets the sibling Element with the indicated name. Element elem = e; while ((elem = nextSiblingElement(elem)) != null) { if (elem.getNodeName().equals(name)) { return elem; return null; |
Element | getSiblingNamed(Element element, String name) Gets the next sibling to the given element with the given name. if (element == null) { return null; Node node = element; while (true) { node = node.getNextSibling(); if (node == null) { return null; ... |