简体   繁体   English

如何检查元素是否具有特定标签? Jsoup Android

[英]How can I check if an Element have an specific tag? Jsoup Android

Jsoup Android Jsoup Android

How can I check if an Element have an specific tag? 如何检查元素是否具有特定标签?

I have a bunch of elements that im using them to display the data in a ListView, such icon, title, description. 我有一堆元素,它们使用它们来在ListView中显示数据,例如图标,标题,描述。 But some element contain a specific tag name and others don't ("object") that I need to link to the element. 但是有些元素包含特定的标签名称,而有些则不需要(“对象”),我需要链接到该元素。

example: 例:

element #1 - no object tag -> skip element 元素#1-无对象标签->跳过元素

element #2 - no object tag -> skip element 元素#2-没有对象标签->跳过元素

element #3 - contain object tag -> extract object data and display to listview item #3 元素#3-包含对象标签->提取对象数据并显示到列表视图项#3

element #4 - no object tag -> skip element 元素#4-没有对象标签->跳过元素

element #5 - contain object tag -> extract object data and display to listview item #5 元素#5-包含对象标签->提取对象数据并显示到列表视图项#5

element #6 - no object tag -> skip element 元素#6-无对象标签->跳过元素

Is there something like this: 是否有这样的事情:

for(int i=0; i < mElements.select("td.ac6").size(); i++){
    if(mElements.select("td.ac6").get(i)...... // something like containTagName("object")
        // extract the tag data
    else
        // skip the element

I've try mElements.select("td.ac6").get(i).select("object").equals("") and equals(null) and nothing. 我尝试了mElements.select(“ td.ac6”)。get(i).select(“ object”)。equals(“”)和equals(null),什么也没有。

if(mElements.select("td.ac6").get(i).select("object").size() > 0)
    // extract the tag data
else
    // skip the element

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

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