Here you can find the source of getNameToNodeList(Node parent, String node_name)
public static Node[] getNameToNodeList(Node parent, String node_name)
//package com.java2s; //License from project: LGPL import org.w3c.dom.*; import java.util.ArrayList; import java.util.List; public class Main { public static Node[] getNameToNodeList(Node parent, String node_name) { List<Node> nodes = new ArrayList<>(); if (parent == null || node_name == null) return nodes.toArray(new Node[0]); NodeList list = parent.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node.getNodeName().equals(node_name)) { nodes.add(node);/*w w w.j a v a2s .com*/ } } return nodes.toArray(new Node[0]); } }