List of utility methods to do XML Last Child Element
Element | getLastChildElement(Node node) Returns the last child element of the specified node, or null if there is no such element. Node child = node.getLastChild(); while (child != null && child.getNodeType() != Node.ELEMENT_NODE) { child = child.getPreviousSibling(); return (Element) child; |
Element | getLastChildElement(Node parent) Finds and returns the last child element node. Node child = parent.getLastChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { return (Element) child; child = child.getPreviousSibling(); return null; ... |
Element | getLastChildElement(Node parent) get Last Child Element if (parent == null || parent.getChildNodes() == null) { return null; NodeList nodes = parent.getChildNodes(); for (int i = nodes.getLength() - 1; i >= 0; i--) { Node child = nodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { return (Element) child; ... |
Element | getLastChildElement(Node start) __UNDOCUMENTED__ NodeList children = start.getChildNodes(); if (children != null) { int len = children.getLength(); Node n = null; for (int i = len - 1; i >= 0; i--) { n = children.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { return ((Element) n); ... |
Element | getLastChildElementNS(Node parent, String uri, String localpart) Finds and returns the last child node with the given qualified name. Node child = parent.getLastChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { String childURI = child.getNamespaceURI(); if (childURI != null && childURI.equals(uri) && child.getLocalName().equals(localpart)) { return (Element) child; child = child.getPreviousSibling(); return null; |
Element | getLastChildWithTagNameNS(Element parent, String namespaceURI, String localName) get Last Child With Tag Name NS final NodeList elements = parent.getElementsByTagNameNS(namespaceURI, localName); return (elements.getLength() > 0) ? (Element) (elements.item(elements.getLength() - 1)) : null; |
Node | getLastNamedChildNode(Node root, String nodeName) get Last Named Child Node Node current = root.getLastChild(); while (current != null) { if (current.getNodeName().equalsIgnoreCase(nodeName)) { return current; current = current.getPreviousSibling(); return null; ... |
Node | getLastNodeChild(Node node) Get the last non-text child of a node. if (node == null) return null; Node child = node.getLastChild(); while (child != null && child.getNodeType() == Node.TEXT_NODE) child = child.getPreviousSibling(); return child; |
Element | getLastVisibleChildElement(Node parent) Finds and returns the last visible child element node. Node child = parent.getLastChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE && !isHidden(child)) { return (Element) child; child = child.getPreviousSibling(); return null; ... |