Here you can find the source of getChildElements(Element parentElement)
parentElement
that are Element s.
Parameter | Description |
---|---|
parentElement | the element to find the children of |
protected static List<Element> getChildElements(Element parentElement)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 Intel Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w w w . j av a 2 s . c om*/ * Dennis Ushakov, Intel - Initial API and Implementation * Oleg Danilov, Intel * *******************************************************************************/ import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Returns a list of child nodes of <code>parentElement</code> that are * {@link Element}s. Returns an empty list if no elements are found. * * @param parentElement * the element to find the children of * @return a node list of the children of parentElement */ protected static List<Element> getChildElements(Element parentElement) { List<Element> list = new ArrayList<Element>(); if (parentElement != null) { NodeList children = parentElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.ELEMENT_NODE) list.add((Element) children.item(i)); } } return list; } }