Mitchell Cameron Mitchell Cameron - 21 days ago 7
Java Question

Get attribute from html with jsoup

There is a

<div id="content">
<form id="fm1" class="fm-v clearfix" action="/cas/login;jsessionid=B91535E9EB93313D6FADBA2C63D10EC2" method="post">
</div>


How to get the value of the action attribute:


"/cas/login;jsessionid=B91535E9EB93313D6FADBA2C63D10EC2"

Answer Source

You don't need to loop it you can simply call like this:

Elements test = doc.select("form");
System.out.println(test.attr("action"));