Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Helma License Notice
 *
 * The contents of this file are subject to the Helma License
 * Version 2.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://adele.helma.org/download/helma/license.txt
 *
 * Copyright 1998-2003 Helma Software. All Rights Reserved.
 *
 * $RCSfile$
 * $Author$
 * $Revision$
 * $Date$
 */

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    /**
     * get first "real" element (ie not the document-rootelement, but the next one
     */
    public static Element getFirstElement(Document document) {
        Element workelement = null;

        if (document.getDocumentElement() != null) {
            org.w3c.dom.Node tmp = document.getDocumentElement().getFirstChild();

            while (tmp != null) {
                tmp = tmp.getNextSibling();

                if (tmp.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
                    workelement = (Element) tmp;

                    break;
                }
            }
        }

        return workelement;
    }
}