最佳答案
您可能正在寻找调用 ownText :
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class Main {
public static void main(String[] args) throws Exception {
final Document document = Jsoup.parse("<html><head/><body><a href=\"#\" class=\"artist\">Soulive<span class=\"create-play\">Play</span></a></body></html>");
final Element elem = document.getElementsByAttributeValue("class", "artist").first();
System.out.println(elem.ownText());
}
}
关于java - Jsoup 从 .text() 中排除 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13424816/