Here you can find the source of getFirstChildElement(Node parent)
Parameter | Description |
---|---|
parent | the node |
private static Element getFirstChildElement(Node parent)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**/*from w ww .ja v a 2 s.co m*/ * Gets the first child element of an element. * @param parent the parent element * @return the first child element or null if there are no child elements */ public static Element getFirstChildElement(Element parent) { return getFirstChildElement((Node) parent); } /** * Gets the first child element of a node. * @param parent the node * @return the first child element or null if there are no child elements */ private static Element getFirstChildElement(Node parent) { NodeList nodeList = parent.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { return (Element) node; } } return null; } }