public static Optional < Element > nextSibling ( final Element element , final String name ) { for ( Node childNode = element . getNextSibling ( ) ; childNode != null ; childNode = childNode . getNextSibling ( ) ) { if ( childNode instanceof Element && ( ( Element ) childNode ) . getTagName ( ) . equalsIgnoreCase ( name ) ) { return Optional . of ( ( Element ) childNode ) ; } } return Optional . absent ( ) ; }
Returns the element s next sibling with a tag matching the given name .