java Jsoup - 获取名称中有空格的类元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14568401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 16:43:16  来源:igfitidea点击:

Jsoup - getting class element with whitespace in name

javajsoup

提问by kincaid

I am trying to grab the value of this class by tag "c2 l n".

我试图通过标签“c2 l n”来获取这个类的值。

<td class="c2 l n"><span class"generic">0,63</span></td>

In Jsoup i have tried this :

在 Jsoup 我试过这个:

String value="c2 l n";
Elements Stock_Data_Change = doc.getElementsByClass(value);

But it keeps coming up empty.. it works fine with other classnames such as "ju.l", it seems to miss the whitespaces. Anyone know a solution for this?

但它一直空着......它与其他类名(如“ju.l”)一起工作正常,它似乎错过了空格。有人知道解决方案吗?

回答by kincaid

As Dave Newton answered in comments above, we are talking about elements,that has multiple classes in them. To get the value of this element, this single line grabs it for me.

正如 Dave Newton 在上面的评论中回答的那样,我们谈论的是元素,其中包含多个类。为了获得这个元素的值,这一行为我抓住了它。

Element Stock_Data_Change = doc.select("td.c2.l.n");