Java tutorial
//package com.java2s; import java.util.ArrayList; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Node getChildNamed(Node node, String name) { return getChildrenNamed(node, name)[0]; } public static Node[] getChildrenNamed(Node node, String name) { ArrayList v = new ArrayList(); NodeList nList = node.getChildNodes(); for (int i = 0; i < nList.getLength(); i++) { Node n = nList.item(i); if (n.getNodeName().equalsIgnoreCase(name)) { v.add(n); } } Node[] nodeArray = new Node[v.size()]; nodeArray = (Node[]) v.toArray(nodeArray); return nodeArray; } }