Java HTML Jsoup Element findNextElementSibling(final Element startElement, final Predicate condition)

Here you can find the source of findNextElementSibling(final Element startElement, final Predicate condition)

Description

find Next Element Sibling

License

Open Source License

Declaration

static Optional<Element> findNextElementSibling(final Element startElement,
            final Predicate<Element> condition) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Optional;

import java.util.function.Predicate;

import org.jsoup.nodes.Element;

public class Main {
    static Optional<Element> findNextElementSibling(final Element startElement,
            final Predicate<Element> condition) {
        for (Element el = startElement.nextElementSibling(); el != null; el = el.nextElementSibling()) {
            if (condition.test(el)) {
                return Optional.of(el);
            }//from w w w. j  av a 2 s.c om
        }

        return Optional.empty();
    }
}

Related

  1. filterElementsByTag(List results, Element element, Set tagSet)
  2. findAElementsWithId(Elements elements, String id)
  3. findAllNodesBefore(Element firstChapter)
  4. findElementsByTag(Element element, String... tags)
  5. findFirstByTag(Element element, String tag)
  6. findPreviousH2Element(Element h3)
  7. findPreviousHElement(Elements sequence, Element reference)
  8. findRootElement(Element element)
  9. firstElement(final Element element, final String... tags)