Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * Preskoci uvodni komentare apod.
     * 
     * @param node
     * @return prvni subelement (jediny - korenovy - element v dokumentu)
     */
    public static Element getFirstElement(Node node) {
        NodeList childNodes = node.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node childNode = childNodes.item(i);
            if (childNode instanceof Element) {
                return (Element) childNode;
            }
        }
        return null;
    }
}