Here you can find the source of filterElementsByTag(List
private static void filterElementsByTag(List<Element> results, Element element, Set<String> tagSet)
//package com.java2s; /**//w w w . j a v a 2 s. c o m * Copyright (C) 2012-2014 Gist Labs, LLC. (http://gistlabs.com) * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.util.List; import java.util.Set; import org.jsoup.nodes.Element; public class Main { private static void filterElementsByTag(List<Element> results, Element element, Set<String> tagSet) { if (tagSet.contains(element.tag().getName().toLowerCase())) results.add(element); for (Element child : element.children()) filterElementsByTag(results, child, tagSet); } }