Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*  
 * XMLUtils.java
 *
 * Copyright (C) August Mayer, 2001-2004. All rights reserved.
 * Please consult the Boone LICENSE file for additional rights granted to you.
 *
 * Created on 09. Dezember 2002, 16:31
 */

import org.w3c.dom.*;

public class Main {
    /**
     * Get a child element with a specific name.
     *
     * @param name Name of the requested child element.
     * @param elem Parent element.
     *
     * @return The first child element with the given name, or null if none found.
     */
    public static Element getChildElement(String name, Element elem) {

        NodeList l = elem.getChildNodes();
        for (int i = 0; i < l.getLength(); i++) {
            Node n = l.item(i);
            if (n instanceof Element && n.getNodeName().equals(name))
                return (Element) n;
        }
        return null;
    }
}