JSoup is used to parse the following html
<input type="checkbox" id="id12" name="renewalCheckboxGroup" value="check1" class="wicket-id11" />
Here is the code of JSoup
Document document = Jsoup.parse("<input type=\"checkbox\" id=\"id12\" name=\"renewalCheckboxGroup\" value=\"check1\" class=\"wicket-id11\" />");
System.out.println(document.id());
Expected result should be id12, however, the returned id is an empty string.
I also try to call attribute(“id”) function as well, but still in vain.
How to solve it? Thank YOu
As far as I know you should select/find/extract your desired
Elementfrom yourdocumentand only then access its attribute (idfor example)You got several options:
or
or
take a look at the docs for more options…
Use selector-syntax to find elements
Use DOM methods to navigate a document