java - Traversing a sibling node in JSOUP based on a search text -


consider below html url. need first perform search on text "student 1" , pick corresponding school in case 'mit school'. how do in jsoup ?

<table> <tbody>  <tr>   <td valign="top">     <div style="border-width:1px;border-color:#cccccc;border-style:solid;">      <table bordercolor="#483d8b">       <tbody>       <tr>         <th colspan="2" bgcolor="#483d8b" height="25"><font face="verdana" size="2" color="white">mit school</font></th>        </tr>        <tr>         <td width="120" height="15"><font face="arial" size="2" color="black"> <b>student 1</b> </font></td>       </tr> </tbody> </table> 

so far have been able perform successful search text.

system.out.println("this :"+jsoup.parse(url, timeout)                         .select("b:containsown(student 1"); 

the output

<b>this :student 1</b> 

i not find many examples online jsoup. one?

i consider each student has dedicated table. then, try following:

    element sibling = doc.select("b:containsown(student 1)")             .first().parent().parent().parent().firstelementsibling();     system.out.println(sibling.select("th").text()); 

note that, in case take consideration first result. have iterate b elements contains 'student 1' in order take data points want.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -