Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Firestar Software, Inc. * 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 * * Contributors: * Firestar Software, Inc. - initial API and implementation * * Author: * Gabriel Oancea * *******************************************************************************/ import org.w3c.dom.*; public class Main { /** * Get the next sibling element of the specified element, null if it has no other siblings. * * @param element The element to search siblings for. * @return The next sibling element, null if it has none. */ public static Element getNextSibling(Element element) { if (element == null) return null; Node node = element.getNextSibling(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) return (Element) node; node = node.getNextSibling(); } return null; } }