Here you can find the source of getLastChild(Node node, String name)
Parameter | Description |
---|---|
node | Node. |
name | Name. |
public static Element getLastChild(Node node, String name)
//package com.java2s; /* Please see the license information at the end of this file. */ import org.w3c.dom.*; public class Main { /** Gets the last child element of a node by name. */*from ww w.j a v a2s. c om*/ * @param node Node. * * @param name Name. * * @return Last child element with given tag name, or * null if none found. */ public static Element getLastChild(Node node, String 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; } return null; } }