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.NodeList;

public class Main {
    /**
     * This method return the first named node with a certain name from a node list
     * 
     * @param list - Investigated list
     * @param name - The wanted name
     * @return The first node with a certain name from a node list
     */
    public static Element getFirstNamedNode(NodeList list, String name) {
        Element result = null;

        for (int i = 0; i < list.getLength(); i++)
            if (list.item(i).getNodeName().equals(name)) {
                result = (Element) list.item(i);
                break;
            }

        return result;
    }
}