rockZ
rockZ

Reputation: 875

Java - jsoup get element with specific string

I would like to select an element that matches a specific String

<img src='http://iblink.ch/resized/sjg63ngi3h3g4a.jpg' alt='tree'>

since I don't have a specific class or div to trigger I try to use getElementsContainingOwnText("resized")

method to get this element. But it does not find it? I also try: getElementsContainingText Same output :(

Anyone have any idea?

Upvotes: 2

Views: 357

Answers (1)

luksch
luksch

Reputation: 11712

The text is the part outside the tags: <tag attribute="value">Text</tag>

So you want to select Elements with a certain attribute value like this:

Elements els = doc.select("img[src*=resized]");

Have a look into CSS selectors as they are implemented in Jsoup.

Upvotes: 1

Related Questions