Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Returns the first node in the node list that is an element. * * @param nodes The list of nodes that contains the element to be * determined. * * @return The first element in the given node list. */ public static Node getFirstElement(NodeList nodes) { for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { return node; } } return null; } }