Here you can find the source of getFirstElementChild(Element elemNode)
Parameter | Description |
---|---|
elemNode | The element whose first element child is to be returned. |
public static Element getFirstElementChild(Element elemNode)
//package com.java2s; /*-------------------------------------------------------------------------------- Copyright (C) 2002, 2004 ISOGEN International http://www.isogen.com/* w w w. j a v a 2 s . c o m*/ This program 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. This program 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 General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --------------------------------------------------------------------------------*/ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Element; public class Main { /** * Returns the first element node within the children of the specified element. * * @param elemNode The element whose first element child is to be returned. */ public static Element getFirstElementChild(Element elemNode) { NodeList nl = elemNode.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node cand = nl.item(i); if (cand.getNodeType() == Node.ELEMENT_NODE) { return (Element) cand; } } return null; } }