Given a HTML code snippet,
<div align="right">...<div>
<p class="text2">abc</p>
I have used jsoup to fetch all elements with their attribute, align
set to right
. Now I want to select the next sibling which i do using, el.nextElementSibling()
How do I verify that the next element is a p
HTML element with a class of text2
? I am new to jsoup and I am learning as I code. Any help would be appreciated! Thanks!
Use Element#getTagName
, which gives you the name of the tag for that element. That same API page also gives you Element#classNames
and a couple of other ways to look at the class
attribute.