2014-02-27 144 views
0

我試圖解析這個html 如何解析它與jsoup? 我想< TD> * </TD之間得到的一切>標籤:jsoup解析tr android

<table border="0" align="center"> 
    <tr> 
     <td><h1><a rel='bookmark' href="http://google.com">google</a></h1></td> 
     <td><font face=tahoma size=2>2014</td></font> 
    </tr> 
    <tr> 
     .. 
    </tr> 

    <tr> 
     .. 
    </tr> 

</table> 

URL url= new URL("http://mylink.html"); 
Document doc = Jsoup.connect(url.toString()).userAgent("Mozila").get(); 
..... 

回答

1

我使用doc.select("td");

String html = "<table border=\"0\" align=\"center\">" 
    +"<tr>" 
     +"<td><h1><a rel='bookmark' href=\"http://google.com\">google</a></h1></td>" 
     +"<td><font face=tahoma size=2>2014</td></font>"; 
      Document doc = Jsoup.parse(html); 
      Elements element=doc.select("td"); 
      for(Element ele:element){ 
     log.d("el","ele.text()");//text() to print in between the text //text() to print in between the text 
      } 
表解析的 td