Java XML Child Node Get getChildNode(Node node, String nodeName)

Here you can find the source of getChildNode(Node node, String nodeName)

Description

get Child Node

License

BSD License

Declaration

public static Node getChildNode(Node node, String nodeName) 

Method Source Code

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

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

public class Main {
    public static Node getChildNode(Node node, String nodeName) {
        if (node.getNodeType() == Node.ELEMENT_NODE) {

            NodeList nodeList = node.getChildNodes();
            for (int i = 0; i < nodeList.getLength(); i++) {
                Node n = nodeList.item(i);
                if (n.getNodeName().equals(nodeName)) {
                    return n;
                }//from ww w . j a  va 2 s . c  o m
            }
        }

        return null;
    }
}

Related

  1. getChildNode(Node node, int index)
  2. getChildNode(Node node, String childName)
  3. getChildNode(Node node, String name)
  4. getChildNode(Node node, String name)
  5. getChildNode(Node node, String name)
  6. getChildNode(Node node, String tag)
  7. getChildNode(Node parent, String childName)
  8. getChildNode(Node parent, String tagName)
  9. getChildNode(Node parentNode, String childElementName)