I have
<div id = top1>
<div id topsub1>
<ul class="student">
<li>
<a href="/thomas">Tom</a>
</li>
</div>
<div id topsub2>
<ul class="student">
<li>
<a href="/thomas1">Tom1</a>
</li>
</div>
</div>
I want to get the href and text
So I did
Elements xx= select (div div ul li)
when I do foreach xx for y and if I do
string1= y.text(); //This is printing Tom
String2= y.attr(“href”) //This is always empty. I am not able to get /thomas?
I also tried y.attr(“a[href]”))
and also what is :
doc.select(“.studentnames > a”);?
does this mean that on the ID=studentnames get all the “a” correct???
What if you simply did
Elements eles = doc.select("a[href]");? Also I believe that when using theattrib(...)method, you don’t pass in the tag, just the attribute name itself.edit:
You state:
Then refine result returned by your select by calling multiple selects sequentially or chaining them:
or perhaps (I’ve never done this):
or even: