Here you can find the source of firstElement(final Element element, final String... tags)
public static final Element firstElement(final Element element, final String... tags)
//package com.java2s; import org.jsoup.nodes.Element; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; public class Main { public static final Element firstElement(final Element element, final String... tags) { Element _element = element; for (String tag : tags) _element = firstChildByTag(_element, tag); return _element; }//from w w w.j a v a 2s . c o m public static final Element firstChildByTag(final Element element, final String tag) { return Iterables.getFirst(childrenByTag(element, tag), null); } public static final Iterable<Element> childrenByTag(final Element element, final String tag) { return Iterables.filter(element.children(), new Predicate<Element>() { public final boolean apply(final Element _element) { return _element.tagName().equals(tag); } }); } }