Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSOUP check if element is img

Tags:

java

html

jsoup

I have an object Elements xxx. Now I want to iterate over it and I would like to check if any element is img tag. How can I do that ?

like image 221
Lubos Mudrak Avatar asked Oct 29 '25 10:10

Lubos Mudrak


1 Answers

You can use the tagName:

Elements yourElements = ...

for( Element element : yourElements )
{
    if( element.tagName().equals("img") == true)
    {
        // It's an 'img'
    }
    else
    {
        // It's not an 'img'
    }
}
like image 98
ollo Avatar answered Oct 30 '25 23:10

ollo