Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Artistic License 

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    /**
     * Returns first DOM node of type element contained within given element.
     *  
     * @param elem element
     */
    public static Element getContainedElement(Element elem) {
        Node n = elem.getFirstChild();
        while (n != null) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                Element e = (Element) n;
                return e;
            }
            n = n.getNextSibling();
        }
        return null;
    }
}