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[] getChildElementNodesByName(Node node, String name) { 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 && (node.getNodeType() == Node.ELEMENT_NODE) && name.equalsIgnoreCase(item.getNodeName())) { elements.add((Element) item); } } } return elements.toArray(new Element[elements.size()]); } }