Java XML NodeList getNodeList(Node fatherNode, String nodeName)

Here you can find the source of getNodeList(Node fatherNode, String nodeName)

Description

Gets a node list from document, given the father node and the children node name.

License

Apache License

Parameter

Parameter Description
fatherNode parent node that containes the node list
nodeName name of the nodes in the resulting node list

Return

NodeList containes node of the given name

Declaration

public static NodeList getNodeList(Node fatherNode, String nodeName) 

Method Source Code

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

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

public class Main {
    /**//from   w ww .jav  a2 s.c  o  m
     * Gets a node list from document, given the father node and the children node name.
     * 
     * @param fatherNode parent node that containes the node list
     * @param nodeName name of the nodes in the resulting node list
     * @return NodeList containes node of the given name
     */
    public static NodeList getNodeList(Node fatherNode, String nodeName) {
        NodeList list = null;
        if (((Element) fatherNode).getElementsByTagName(nodeName) != null) {
            list = ((Element) fatherNode).getElementsByTagName(nodeName);
        }
        return list;
    }
}

Related

  1. getNodeFromNodeList(NodeList list, String name)
  2. getNodeFromNodeList(NodeList nl, String nodeName, int index)
  3. getNodeFromNodeList(NodeList nodeList)
  4. getNodeIntValue(String tagName, NodeList nodes)
  5. getNodeList(Element from, String elementName)
  6. getNodeList(Node node, String tagName)
  7. getNodeList(Node pNode, String tagName)
  8. getNodeList(NodeList nl, String[] names, int pos)
  9. getNodeList(NodeList nodeList)