【问题标题】:compare jsoup elements比较jsoup元素
【发布时间】:2012-03-23 20:04:19
【问题描述】:

大家好,我正在尝试将一个 jsoup 元素与所有其他元素进行比较,如果两个元素相等,我需要计数++;在这种情况下,我需要将链接 1 中的所有元素与链接 2 链接 3 链接 4 中的所有元素....

Document document1 = Jsoup.parse(webPage1);
Elements links1 = document1.select("example");

Document document2 = Jsoup.parse(webPage2);
Elements links2 = document2.select("example");

Document document3 = Jsoup.parse(webPage3);
Elements links3 = document3.select("example");

Document document4 = Jsoup.parse(webPage4);
Elements links4 = document4.select("example");

JSP 中的代码是什么......

【问题讨论】:

    标签: java javascript jsp jsoup


    【解决方案1】:

    Elements 只是一个Element 的列表,所以匹配看起来像:

       for (Element element : links1) {
                if(links2.contains(element)){
                    count++;
                }
                //maybe do the same thing with links3 links4.
            }
    

    如果您想在 JSP 中进行 - 这是另一个问题。

    【讨论】:

      猜你喜欢
      • 2016-01-21
      • 1970-01-01
      • 1970-01-01
      • 2021-07-04
      • 2022-01-08
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      • 2022-12-17
      相关资源
      最近更新 更多