jSoup检查span类是否存在 [英] jSoup to check if a span class exists
本文介绍了jSoup检查span类是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下格式的HTML
I have a HTML with the following format
<article class="cik" id="100">
<a class="ci" href="/abc/1001/STUFF">
<img alt="Micky Mouse" src="/images/1001.jpg" />
<span class="mick vtEnabled"></span>
</a>
<div>
<a href="/abc/1001/STUFF">Micky Mouse</a>
<span class="FP">$88.00</span> <span class="SP">$49.90</span>
</div>
</article>
在上面的代码中,文章内的标签具有没有标签的span class ="mick vtEnabled".我想检查一下在文章标签中是否存在具有指定类名的span标签.我怎么做?我尝试了select(> a [href]> span.mick vtEnabled")并检查了大小.所有文章标签的大小均为0,无论是否设置.有输入吗?
In the above code the tag inside article has a span class="mick vtEnabled" with no lable. I want to check if this span tag with the class name specified is present within the article tag. How do i do that? I tried select("> a[href] > span.mick vtEnabled") and checked the size..it remains 0 for all the article tags irrespective if its set or not. any inputs?
推荐答案
此
Elements divs = doc.select("article > a[href] > span[class=mick vtEnabled]");
选择具有两个类的div.
selects the div with the two classes.
这篇关于jSoup检查span类是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文