Here you can find the source of getChildNodesByName(Element parent, String name)
public static Node[] getChildNodesByName(Element parent, String name)
//package com.java2s; //License from project: Open Source License 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 Node[] getChildNodesByName(Element parent, String name) { List<Node> nodeList = new ArrayList<Node>(); NodeList childNodes = parent.getChildNodes(); int length = childNodes.getLength(); for (int i = 0; i < length; i++) { Node current = childNodes.item(i); if (current.getNodeName().equals(name)) nodeList.add(current);/* w w w .j ava2 s. c o m*/ } Node[] nodes = new Node[nodeList.size()]; nodeList.toArray(nodes); return nodes; } }