问题描述
<div class="fr">
<div id="newssource">
<a href="http://nhl.com" class="newssourcelink" target="_blank">
Philadelphia Flyers
</a>
</div>
April 15, 2014, 11:13 a.m.
</div>
我用Jsoup提取从网站文字Android应用程序的工作,在上面的HTML我想只得到父DIV的文本。我想要的是显示日期和放大器;时间是在课堂上FR的父DIV。
I am working with Android Application using Jsoup for extracting text from website, in the above Html I want to get text of the parent div only. What I want is to display Date & Time which is in the parent div of class "fr".
for(Element detailsDate:document.getElementsByClass("fr")){
newsDate.add(
detailsDate.clone().children().remove().last().text().trim()
);
}
这是我与获取文本完成 - 从孩子的div只GETD文本,即费城飞人,这是在一的标签,但我不需要这个文本。我想只显示日期和放大器;时间。
This is what I done with getting text - it only getd text from child div, i.e "Philadelphia Flyers" which is in the "a" tag, but I don't need this text. I want to display only Date & Time.
请帮我整理出这个问题结果
由于提前
Please help me sorting out this problem
Thanks in Advance
推荐答案
下面的jQuery code使用得到的只有日期和时间格式FR的div
use below jQuery code to get only Date and Time form "fr" div
<script>
jQuery('.fr').each(function(){
var textValue = jQuery(this).clone() //clone the element
.children() //select all the children
.remove() //remove all the children
.end() //again go back to selected element
.text();
alert(textValue);
});
</script>
这篇关于如何从只在Android中使用Jsoup父格文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!