Neil Neil - 2 years ago 74
Java Question

How to parse using jsoup


<div class="alert_right">
<p>welcome!<script>setTimeout("window.location.href ='index.php';", 1000);</script></p></div>

How to get the welcome! text using Jsoup?

Answer Source

If your HTML is in a String, you can use the following code:

Document doc = Jsoup.parse(HTML);
Elements div =".alert_right > p:nth-child(1)");
String s = div.text();

Now s is welcome!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download