Reputation: 576
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. 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
element #2 - no object tag -> skip element
element #3 - contain object tag -> extract object data and display to listview item #3
element #4 - no object tag -> skip element
element #5 - contain object tag -> extract object data and display to listview item #5
element #6 - no object tag -> skip element
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.
Upvotes: 1
Views: 1331
Reputation: 3413
if(mElements.select("td.ac6").get(i).select("object").size() > 0)
// extract the tag data
else
// skip the element
Upvotes: 2