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 getChildNodeByName(Node parentNode, String nodeName) {
        NodeList nodes = parentNode.getChildNodes();
        Node childNode = null;

        for (int i = 0; i < nodes.getLength(); i++) {
            if (nodes.item(i).getNodeName().equals(nodeName)) {
                childNode = nodes.item(i);
                break;
            }
        }
        return childNode;
    }
}