How to parse span title with jsoup?
i am trying to parse the title of this content using JSOUP..
<div class="article">
<div class="articleHead review">
<h1 class="item"><span class="fn">OnLive</span> review</h1>
&开发者_开发技巧lt;h2 class="subGrey"><span class=""></span>Cloud gaming has arrived in the UK, but can our infrastructure make the most of it?</h2>
I want to parse the span class OnLive Review. and the sub header
ive tried this so far..
try{
Elements titleElements = jsDoc.getElementsByTag("div");
for(Element TitleElement : titleElements){
if(TitleElement.attr("class").equals("articleHeader review")){
Element articleHeader = jsDoc.select("#item").first();
String header = articleHeader.text();
System.out.println(TitleElement.text());
title = header.toString();
Log.e("TITLE", title);
}
}
}
catch(Exception e){
System.out.println("Couldnt get content");
}
No luck.
There you go:
Element header = jsDoc.select("h1.item span.fn");
Element sub = jsDoc.select("h2.subGrey span");
精彩评论