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 {
    /**
     * @param node
     * @param name
     * @return the first child node with the given name or <code>null</code>
     * if none found
     */
    public static Node findChild(Node node, String name) {
        NodeList nl = node.getChildNodes();
        int len = nl.getLength();
        Node child;
        for (int i = 0; i < len; i++) {
            child = nl.item(i);
            if (name.equals(child.getNodeName())) {
                return child;
            }
        }
        return null;
    }
}