List of utility methods to do XML Last Child Element
Element | getLastChild(Element e) get Last Child if (e == null) return null; Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getPreviousSibling(); return (Element) n; |
Element | getLastChild(Element element) get Last Child NodeList children = element.getChildNodes(); Node child; Element last = null; for (int index = 0; index < children.getLength(); index++) { child = children.item(index); if ((child instanceof Element)) { return last = (Element) child; return last; |
Element | getLastChild(Element parent, String name) get Last Child Element child = null; NodeList nl = parent.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i); if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equals(name)) { child = (Element) n; return child; |
Element | getLastChild(Node node, String name) Gets the last child element of a node by name. NodeList children = node.getChildNodes(); int numChildren = children.getLength(); for (int i = numChildren - 1; i >= 0; i--) { Node child = children.item(i); if (child.getNodeType() != Node.ELEMENT_NODE) continue; if (child.getNodeName().equals(name)) return (Element) child; ... |
Element | getLastChildElement(Element e) Get the last child of e which is an element, or null if there is no such element.
Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getPreviousSibling(); return (Element) n; |
Element | getLastChildElement(Element e) Get the last child of e which is an element, or null if there is no such element.
Node n = e.getLastChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getPreviousSibling(); return (Element) n; |
Element | getLastChildElement(Element elem) get Last Child Element if (elem == null) { return null; for (Node n = elem.getLastChild(); n != null; n = n.getPreviousSibling()) { if (n.getNodeType() == Node.ELEMENT_NODE) { return (Element) n; return null; |
Element | getLastChildElement(Node n) Gets the last child Element of the node, skipping any Text nodes such as whitespace. Node child = n.getLastChild(); while (child != null && child.getNodeType() != Node.ELEMENT_NODE) child = child.getPreviousSibling(); if (child != null) return (Element) child; else return null; |
Element | getLastChildElement(Node node) get Last Child Element Node child = node.getLastChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { return (Element) child; child = child.getPreviousSibling(); return null; ... |
Element | getLastChildElement(Node node) Gets the last child element of a node. node = node.getLastChild(); while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getPreviousSibling(); return (Element) node; |