Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    /**
     * Returns next sibling element node
     * @param element
     * @return
     */
    protected static Element getNextSiblingElement(Element element) {
        try {
            Node tmpNode = null;
            tmpNode = element.getNextSibling();

            while (tmpNode.getNodeType() != Node.ELEMENT_NODE) {
                //fix for structure that has more than two parents null 
                if (tmpNode.getNextSibling() == null)
                    tmpNode = tmpNode.getParentNode();
                tmpNode = tmpNode.getNextSibling();
            }
            return (Element) tmpNode;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }
}