开发者

Jsoup select div having multiple classes

I am trying to select, using Jsoup, a <div> that has multiple classes:

<div class="content-text right-align bold-font">...</div>

The syntax for doing so, to the best of my understanding, should be:

document.select("div.content-text.right-align.bold-font");

However, for some reason, this doesn't work for me.

When I try the same exact syntax on JSFIDDLE, it works without a hitch.

Does multi-class selection work in Jsoup?

(I'd rather find out that this is a bug in my code开发者_如何学编程 than find out that this is a Jsoup limitation :)

UPDATE (thanks to the answer below): Jsoup works perfectly with the aforementioned syntax.


Works for me with latest Jsoup (1.5.2).

String html = "<div class=\"content-text right-align bold-font\">foo</div>";
Document document = Jsoup.parse(html);
Elements elements = document.select("div.content-text.right-align.bold-font");
System.out.println(elements.text()); // foo

So either you're possibly using an outdated version of Jsoup which exposes a bug related to this, or the actual HTML doesn't contain a <div> like that.


It would by helpfull for you in near future. Have fun.

Jsoup selectors, jQuery selectors

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜