Here you can find the source of getChildElements(Element parent, String name)
public static Element[] getChildElements(Element parent, String name)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 Chase Technology Ltd - http://www.chasetechnology.co.uk * 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 ww . j a va2 s . c o m*/ * Doug Satchwell (Chase Technology Ltd) - initial API and implementation *******************************************************************************/ 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 { public static Element[] getChildElements(Element parent, String name) { List<Element> children = new ArrayList<Element>(); NodeList list = parent.getChildNodes(); int length = list.getLength(); for (int i = 0; i < length; ++i) { Node node = list.item(i); short type = node.getNodeType(); if (type == Node.ELEMENT_NODE) { Element processorElement = (Element) node; if (processorElement.getNodeName().equals(name)) { children.add(processorElement); } } } return children.toArray(new Element[0]); } }