Here you can find the source of getAllElements(Element config, String elementName)
public static List<Element> getAllElements(Element config, String elementName)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**// w w w. j a va2s. com * returns all the element with the given name */ public static List<Element> getAllElements(Element config, String elementName) { List<Element> out = new ArrayList<Element>(); NodeList children = config.getChildNodes(); for (int counter = 0; counter < children.getLength(); counter++) { if (children.item(counter) instanceof Element) { Element el = (Element) children.item(counter); if (el.getTagName().equals(elementName)) { out.add(el); } } } return out; } }