Here you can find the source of getFirstChild(Element element)
Parameter | Description |
---|---|
element | the element to get the child element from |
public static Element getFirstChild(Element element)
//package com.java2s; //License from project: LGPL import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**/*from ww w .ja va 2 s. com*/ * Get the first child element of a document element. The method returns null if no child element is available or if * the specified element is null. * * @param element the element to get the child element from * @return the first child element of the given element */ public static Element getFirstChild(Element element) { if (element == null) return null; NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { return (Element) list.item(i); } } return null; } }