简体   繁体   中英

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?

Change "div.abcd > span"

to

"div.abcd span"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM