Java XML NodeList findElementsIgnoreCase(String name, NodeList nodes)

Here you can find the source of findElementsIgnoreCase(String name, NodeList nodes)

Description

Returns a list (possibly empty) with any Elements in the list of nodes with the given name (case insensitive).

License

Open Source License

Parameter

Parameter Description
name a parameter
nodes a parameter

Return

a list; never null

Declaration

public static LinkedList<Element> findElementsIgnoreCase(String name, NodeList nodes) 

Method Source Code

//package com.java2s;
/**/*from  w ww. jav  a 2  s  .c om*/
 * 
 * This file is part of SavoyCraft.
 * 
 * SavoyCraft is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * SavoyCraft 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 Lesser General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with SavoyCraft. If not, see <http://www.gnu.org/licenses/>.
 * 
 */

import java.util.LinkedList;

import org.w3c.dom.Element;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    /**
     * Returns a list (possibly empty) with any Elements in the list of nodes
     * with the given name (case insensitive).
     * 
     * @param name
     * @param nodes
     * @return a list; never null
     */
    public static LinkedList<Element> findElementsIgnoreCase(String name, NodeList nodes) {
        LinkedList<Element> found = new LinkedList<Element>();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node n = nodes.item(i);
            if (n.getNodeType() == Node.ELEMENT_NODE && n.getNodeName().equalsIgnoreCase(name)) {
                found.add((Element) n);
            }
        }
        return found;
    }
}

Related

  1. extractElementsFromNodeList(NodeList config, String tag, boolean required)
  2. extractNodeListFromElement(Element config, String tag, boolean required)
  3. fillHashtable(NodeList list, Hashtable fillIn)
  4. fillHashtable(NodeList list, Hashtable fillIn)
  5. findElement(NodeList elements, String elementName)
  6. findNode(NodeList nodeList, String nodeName)
  7. findNode(NodeList nodes, String nodeName)
  8. findNode(String id, NodeList orgs)
  9. findNodeByName(NodeList nodeList, String name)