Here you can find the source of getNodeFromNodeList(NodeList nl, String nodeName, int index)
Parameter | Description |
---|---|
nl | The node list |
nodeName | The node name |
public static Node getNodeFromNodeList(NodeList nl, String nodeName, int index)
//package com.java2s; /*/* w w w .jav a 2s. c o m*/ * Copyright (C) 2003 by Francois Guillet * 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 2 of the License, or (at your option) 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. */ import org.w3c.dom.*; public class Main { /** * Gets a named node from a node list. Returns null if the node does not * exist. * *@param nl The node list *@param nodeName The node name *@return The node named nodeName */ public static Node getNodeFromNodeList(NodeList nl, String nodeName, int index) { for (int i = 0; i < nl.getLength(); ++i) { Node n = nl.item(i); if (n.getNodeName().equals(nodeName)) { if (index-- == 0) return n; } } return null; } }