2011-10-07 44 views
0

我试图解析使用JSOUP此内容的标题..如何用jsoup解析跨度标题?

<div class="article"> 
<div class="articleHead review"> 

    <h1 class="item"><span class="fn">OnLive</span> review</h1> 
    <h2 class="subGrey"><span class=""></span>Cloud gaming has arrived in the UK, but can our infrastructure make the most of it?</h2> 

我想分析跨度类OnLive的审查。 和子头

香港专业教育学院尝试这样做,到目前为止..

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"); 
        } 

没有运气。

回答

1

你去那里:

Element header = jsDoc.select("h1.item span.fn"); 
Element sub = jsDoc.select("h2.subGrey span");