Java Utililty Methods XML Last Child Element

List of utility methods to do XML Last Child Element

Description

The list of methods to do XML Last Child Element are organized into topic(s).

Method

ElementgetLastChild(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;
ElementgetLastChild(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;
ElementgetLastChild(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;
ElementgetLastChild(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;
...
ElementgetLastChildElement(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;
ElementgetLastChildElement(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;
ElementgetLastChildElement(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;
ElementgetLastChildElement(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;
ElementgetLastChildElement(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;
...
ElementgetLastChildElement(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;