<div></div>
<div></div>
<div></div>
<div></div>
<ul>
<form id=the_main_form method="post">
<li>
<div></div>
<div> <h2>
<a onclick="xyz;" target="_blank" href="http://sample.com" style="text-decoration:underline;">This is sample</a>
</h2></div>
<div></div>
<div></div>
</li>
there are 50 li’s like that
I have posted the snip of the html from a big HTML.
<div> </div> => means there is data in between them removed the data as it is not neccessary.
I would like to know how the JSOUP- select statement be to extract the href and Text?
I selected doc.select(“div div div ul xxxx”);
where xxx is form ..shoud I give the form id (or) how should I do that
Try this:
Hope it helps!
EDIT:
This part of the code gets all
<li>tags that are inside the<form>with id#the_main_form.Then we iterate over all the
<li>tags and get<a>tags, by first getting<div>tags ( the second one inside all<li>s by using index=1 ->div:eq(1)) then getting<h2>tags, where our<a>tags are present.Hope you understand now! 🙂