Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.util.ArrayList; public class Main { public static Element[] getChildElementNodes(Node node) { if (node == null) { return null; } ArrayList<Element> elements = new ArrayList<>(); NodeList nodeList = node.getChildNodes(); if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); if (item != null && item.getNodeType() == Node.ELEMENT_NODE) { elements.add((Element) item); } } } return elements.toArray(new Element[elements.size()]); } }