Here you can find the source of getFirstElement(NodeList nodes)
Parameter | Description |
---|---|
nodes | The list of nodes that contains the element to be determined. |
public static Node getFirstElement(NodeList nodes)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**// w w w.jav a2 s. c o m * 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; } }