Here you can find the source of getFirstLevelChildElements(Element parent)
public static final List<Element> getFirstLevelChildElements(Element parent)
//package com.java2s; 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 final List<Element> getFirstLevelChildElements(Element parent) { NodeList nodeList = parent.getChildNodes(); ArrayList<Element> childList = new ArrayList<Element>(nodeList.getLength()); Node childNode = parent.getFirstChild(); while (childNode != null) { if (childNode.getNodeType() == Node.ELEMENT_NODE) { childList.add((Element) childNode); }/* ww w .j a va 2 s .c om*/ childNode = childNode.getNextSibling(); } return childList; } }