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; public class Main { /** * Return array of children nodes by node name */ public static Node[] childrenByNodeName(Element owner, String searchNode) { NodeList list = owner.getElementsByTagName(searchNode); Node[] children = new Node[list.getLength()]; for (int i = 0; i < children.length; i++) { if (isElement(list.item(i)) && searchNode.equalsIgnoreCase(list.item(i).getLocalName())) { children[i] = list.item(i); } } return children; } public static boolean isElement(Node node) { return node.getNodeType() == Node.ELEMENT_NODE; } }