Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {

    public static Node getChildNode(Node parentNode, String nodeName) {
        Node node = null;
        NodeList nodeList = parentNode.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node childNode = nodeList.item(i);
            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                if (((Element) childNode).getNodeName().equals(nodeName)) {
                    node = childNode;
                    break;
                }
            }
        }
        return node;
    }
}