Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**
     * Determines the first child node of the parent with the specified tag
     * name.
     * 
     * @param parent   The parent node of the child node to be determined.
     * @param nodeName The name of the child node to be determined.
     * 
     * @return The determined child node with the given name.
     */
    public static Node getChildWithName(Node parent, String nodeName) {
        if (parent != null) {
            NodeList childs = parent.getChildNodes();
            for (int i = 0; i < childs.getLength(); i++) {
                Node child = childs.item(i);
                if ((child.getLocalName() != null) && child.getLocalName().equals(nodeName)) {
                    return childs.item(i);
                }
            }
        }
        return null;
    }
}