Here you can find the source of getNodeByNodeName(NodeList nodes, String nodeName)
private static Node getNodeByNodeName(NodeList nodes, String nodeName)
//package com.java2s; /*//from w ww. j ava 2 s.c o m * AutoRefactor - Eclipse plugin to automatically refactor Java code bases. * * Copyright (C) 2014 Jean-No?l Rouvignac - initial API and implementation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program under LICENSE-GNUGPL. If not, see * <http://www.gnu.org/licenses/>. * * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution under LICENSE-ECLIPSE, and is * available at http://www.eclipse.org/legal/epl-v10.html */ import java.util.ArrayList; import java.util.List; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { private static Node getNodeByNodeName(NodeList nodes, String nodeName) { for (Node node : asList(nodes)) { if (nodeName.equals(node.getNodeName())) { return node; } } return null; } private static List<Node> asList(NodeList nodeList) { final List<Node> results = new ArrayList<Node>(); int length = nodeList.getLength(); for (int i = 0; i < length; i++) { final Node item = nodeList.item(i); if (item.getNodeType() != Node.TEXT_NODE) { results.add(item); } } return results; } }