且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jsoup多元素输出

更新时间:2023-12-03 21:23:04

如果您只是想同时选择两者,则可以执行以下操作:

If you are just trying to select both at the same time, you can do something like this:

for (Element link : document.select("a.yschttl, div.abstr") {
    out.println(link);
}

如果您要进行两个选择并一并输出这些值,则必须执行类似@vacuum建议的操作,但要注意列表的长度.

If you are trying to make two selections and outputting those values in tandem, you will have to do something like @vacuum suggests, but being careful of the lengths of the lists.

一个旁注,您不必两次分析文档即可进行两个选择.您可以解析一次,然后选择两次.

A side note, you don't have to parse the document twice to make two selections. You can parse once and select twice.