jsoup引号和空格

Reg*_*kie 5 jsoup

我试图使用Jsoup选择以下HTML代码段中的段落:

<div class="abc ">
<p class="de">Very short paragraph.</p>
</div>
Run Code Online (Sandbox Code Playgroud)

为此,我使用以下Java代码片段:

Elements divs = document.select("div[class=abc ]");
for (Element div : divs) {
  Log.v("iwashere", String.format("div[class=abc ]"));
  Elements ppp = document.select("p[class=de]");                   
  for (Element p : ppp) {
    Log.v("iwashere", p.text());
    break;                                                
  } 
}
Run Code Online (Sandbox Code Playgroud)

问题是,由于某种原因,Jsoup似乎没有拿起"DIV [CLASS = ABC]"(在Log.v("iwashere")一直没有出现在日志中.

起初,我认为尾随空间可能是一个问题,所以我也尝试过

Elements divs = document.select("div[class=abc]");
Run Code Online (Sandbox Code Playgroud)

但这也没有帮助.

上面的代码可能有什么问题?

Ric*_*der 5

jsoup使用css选择器.你想使用"div.abc",这意味着一个具有abc类的div.

Element divs = document.select("div.abc");
Run Code Online (Sandbox Code Playgroud)