Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Cilea Commons Framework
 * 
 * Copyright (c) 2008, CILEA and third-party contributors as
 *  indicated by the @author tags or express copyright attribution
 *  statements applied by the authors.  All third-party contributions are
 *  distributed under license by CILEA.
 * 
 *  This copyrighted material is made available to anyone wishing to use, modify,
 *  copy, or redistribute it subject to the terms and conditions of the GNU
 *  Lesser General Public License v3 or any later version, as published 
 *  by the Free Software Foundation, Inc. <http://fsf.org/>.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 *  for more details.
 * 
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this distribution; if not, write to:
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor
 *   Boston, MA  02110-1301  USA
 */

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

public class Main {
    /**
     * Restituisce il primo sottoelemeto di xmlRoot trovato con il nome
     * specificato
     * 
     * @param xmlRoot
     *            l'elemento in cui cercare (NOT null)
     * @param name
     *            il nome del sottoelemento da restituire
     * @return il primo sottoelemento trovato o null se non presente
     */
    public static Element getSingleElement(Element xmlRoot, String name) {
        NodeList nodeList = xmlRoot.getElementsByTagName(name);
        Element element = null;
        if (nodeList != null && nodeList.getLength() > 0) {
            element = (Element) nodeList.item(0);
        }
        return element;
    }
}