Here you can find the source of getFirstChildElement(Node node)
Parameter | Description |
---|---|
node | The node whose children should be iterated. |
public static Element getFirstChildElement(Node node)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**// w ww .j av a2s . co m * Get the first child node that is an element node. * * @param node The node whose children should be iterated. * @return The first child element or {@code null}. */ public static Element getFirstChildElement(Node node) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { return (Element) children.item(i); } } return null; } }