Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015-2016 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    /** Look for Element node.
     *
     *  <p>Checks the node and its siblings.
     *  Does not descent down the 'child' links.
     *
     *  @param node Node where to start.
     *  @return Returns node, next Element sibling or <code>null</code>.
     */
    public static final Element findElement(Node node) {
        while (node != null) {
            if (node.getNodeType() == Node.ELEMENT_NODE)
                return (Element) node;
            node = node.getNextSibling();
        }
        return null;
    }
}