Yassir Arafat Roni
Yassir Arafat Roni

Reputation: 292

How to parse "text" from span class with Jsoup

I want to parse the text in span class with Jsoup. Here is my Html code portion.

<html>
<head></head>
<body>
<div>
<div class = "abcd">
<span> This is text </span>
</div>
<div>
</body>
</html>

I wrote something like that

Element element =  doc.select("div.abcd > span");
System.out.println("Text = "+element.text());

This isn't working. Is there any other way to do this?

Upvotes: 4

Views: 1549

Answers (1)

Harry T.
Harry T.

Reputation: 3527

Change "div.abcd > span"

to

"div.abcd span"

Upvotes: 2

Related Questions