Java XML NodeList getNodeListByName(Node node, String name, List finalNodeList)

Here you can find the source of getNodeListByName(Node node, String name, List finalNodeList)

Description

get Node List By Name

License

Apache License

Declaration

public static List<Node> getNodeListByName(Node node, String name, List<Node> finalNodeList) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

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

public class Main {
    public static List<Node> getNodeListByName(Node node, String name, List<Node> finalNodeList) {
        NodeList nodeList = node.getChildNodes();
        System.out.println("child node name: " + node.getNodeName());
        if (nodeList == null)
            return null;

        for (int i = 0; i < nodeList.getLength(); i++) {
            Node candNode = nodeList.item(i);
            if (candNode.getNodeName().equals(name)) {
                finalNodeList.add(candNode);
            }/*from   w w  w. j a  v  a 2  s. c  o  m*/

            getNodeListByName(nodeList.item(i), name, finalNodeList);

        }
        return finalNodeList;
    }
}

Related

  1. getNodeList(Node pNode, String tagName)
  2. getNodeList(NodeList nl, String[] names, int pos)
  3. getNodeList(NodeList nodeList)
  4. getNodeList(NodeList nodeList)
  5. getNodeListAsList(NodeList nl)
  6. getNodeListItems(NodeList nodeList)
  7. getNodeListLength(NodeList list)
  8. getNodes(String tagName, NodeList nodes)
  9. getNodesByName(String name, NodeList nodeList)