Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * @param node * @return */ public static Element getLastElement(Node node) { NodeList children = node.getChildNodes(); if (children == null || children.getLength() == 0) { return null; } int len = children.getLength(); for (int i = len - 1; i >= 0; i--) { Node n = children.item(i); if (n instanceof Element) { return (Element) n; } } return null; } }