简体   繁体   English

jsoup检查表是否存在

[英]jsoup checking if a table exsists

I have 我有

Element list = doc.select("table").get(0); 元素列表= doc.select(“ table”)。get(0);

some times there is no table present, but I am still doing get so I am 有时候没有桌子,但是我仍然在做,所以我

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

How to get out of this exception? 如何摆脱这种例外? there is no size as this is element 没有大小,因为这是元素

Elements is the object returned from a select. Elements是从选择返回的对象。

 Elements tables = doc.select("table");

and it has a size method. 它有一个大小的方法。 So you can call: 因此,您可以致电:

 tables.size();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM