Mega Code Archive

 
Categories / Java / XML
 

Get the next sibling element

import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Utils {   /**    * Get the next sibling element    * @param el    * @return    */   public static Element getNextSiblingElement(Element el) {       for (Node n = el.getNextSibling(); n != null; n = n.getNextSibling()) {           if (n instanceof Element) {               return (Element) n;           }       }       return null;   } }