Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    /**
     * This method gets the child node with the provided name from the 
     * provided start node.
     * @param start The Parent node to scan children.
     * @param nodeName The name of the node that we're looking for.
     * @return The Node with name: nodeName, whose parent is the start node.
     *
     * @author <a href='mailto:intere@gmail.com'>Eric Internicola</a>
     */
    public static Node getChildNode(Node start, String nodeName) {
        Node child = null;

        NodeList children = start.getChildNodes();

        for (int i = 0; i < children.getLength(); i++) {
            Node n = children.item(i);

            if (nodeName.equals(n.getNodeName())) {
                child = n;
                break;
            }
        }

        return child;
    }
}