Here you can find the source of getNextSiblingElement(Node node)
public static Element getNextSiblingElement(Node node)
//package com.java2s; // License as published by the Free Software Foundation; either import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element getNextSiblingElement(Node node) { Node nextSibling = node.getNextSibling(); while (nextSibling != null) { if (nextSibling.getNodeType() == Node.ELEMENT_NODE) { return (Element) nextSibling; }//www . j a v a 2 s .co m nextSibling = nextSibling.getNextSibling(); } return null; } }