Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static Node getNodeChildByName(Node parentNode, String childNodeName) {
        Node childNode = null;
        NodeList childNodeList = parentNode.getChildNodes();
        int len = childNodeList.getLength();
        for (int i = 0; i < len; i++) {
            Node tmpChildNode = childNodeList.item(i);
            if (tmpChildNode.getNodeName().equals(childNodeName)) {
                return tmpChildNode;
            }
        }
        childNode = null;
        return childNode;
    }
}