Select "name" in JSoup

I have several divs in the url of a webpage that I have to parse, having the same class name but different names without id.

eg,

<div class="answer" style="display: block;" name="yyy" oldblock="block" jQuery1317140119108="11"> 

and

<div class="answer" style="display: block;" name="xxx" oldblock="block" jQuery1317140119108="11">

I want to select the data and analyze only one of the divs, namely (name = "yyy") (the contents inside the div are <href>links that differ for each class.

I looked at the selector syntax on the Jsoup webpage, but cannot find a way around it. Could you help me with this or let me know if I missed something?

+5
source share
1 answer

Use the selector [attributename=attributevalue].

Elements xxxDivs = document.select("div.answer[name=xxx]");
// ...

Elements yyyDivs = document.select("div.answer[name=yyy]");
// ...
+10

All Articles