Here you can find the source of getFirstElementChild(Element aElement)
aElement
DOM Element.
Parameter | Description |
---|---|
aElement | Element to scan for the first element. |
null
otherwise.
public static Element getFirstElementChild(Element aElement)
//package com.java2s; /*********************************************************** Copyright (C) 2004 VeriSign, Inc.//from ww w . jav a2s . c o m This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://www.verisign.com/nds/naming/namestore/techdocs.html ***********************************************************/ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Gets the first DOM Element Node of the <code>aElement</code> DOM Element. * * @param aElement * Element to scan for the first element. * @return Found DOM Element Node if found; <code>null</code> otherwise. */ public static Element getFirstElementChild(Element aElement) { NodeList children = aElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { return (Element) children.item(i); } } return null; } }