Here you can find the source of getElementArray(Element config, String elementName)
public static Element[] getElementArray(Element config, String elementName)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Element[] getElementArray(Element config, String elementName) { NodeList children = config.getChildNodes(); Node node;//from ww w .ja v a 2s. co m ArrayList arrayList = new ArrayList(); for (int counter = 0; counter < children.getLength(); counter++) { node = children.item(counter); if (node instanceof Element) { if (((Element) node).getTagName().equals(elementName)) { arrayList.add(node); } } } Element[] elementArray = new Element[arrayList.size()]; elementArray = (Element[]) arrayList.toArray(elementArray); return elementArray; } }