Java XML Child Node Get getChildNodesByName(Node node, String name)

Here you can find the source of getChildNodesByName(Node node, String name)

Description

get Child Nodes By Name

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

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

public class Main {
    public static List<Node> getChildNodesByName(Node node, String name) {
        List<Node> result = new ArrayList<Node>();

        NodeList childList = node.getChildNodes();

        for (int i = 0; i < childList.getLength(); ++i) {
            Node child = childList.item(i);
            if (child.getNodeName().equals(name)) {
                result.add(child);//  w w w.ja  v a2s . co  m
            }
        }

        return result;
    }
}

Related

  1. getChildNodes(Node rootNode, String childName)
  2. getChildNodesByName(Element parent, String name)
  3. getChildNodesByName(Node element, String name, boolean caseSensitive)
  4. getChildNodesByName(Node element, String name, boolean caseSensitive)
  5. getChildNodesByName(Node element, String name, boolean caseSensitive)
  6. getChildNodesByTagName(final Element element, final String tagName)
  7. getChildNodesWithName(Node node, String name)
  8. getChildNodeText(Element element, String nodeTagName)
  9. getChildNodeText(Node root, String childName)