java - Select next node after specific condition -


i'm trying select next node value (number 4) after span tag in html below. how can that??

<tr valign="top">     <td></td>     <td><a href="#"> 1 </a></td>     <td><a href="#"> 2 </a></td>     <td><span> 3 </span></td>     <td><a href="#"> 4 </a></td>     <td><a href="#"> 5 </a></td>     <td><a href="#"> 6 </a></td> </tr> 

final string html = "<tr valign=\"top\">\n"         + "    <td></td>\n"         + "    <td><a href=\"#\"> 1 </a></td>\n"         + "    <td><a href=\"#\"> 2 </a></td>\n"         + "    <td><span> 3 </span></td>\n"         + "    <td><a href=\"#\"> 4 </a></td>\n"         + "    <td><a href=\"#\"> 5 </a></td>\n"         + "    <td><a href=\"#\"> 6 </a></td>\n"         + "</tr>";  document doc = jsoup.parse(html);  element nexttospan = doc.select("span").first().nextelementsibling(); 

explained:

doc.select("span") // select span-tags of doc     .first()    // retrieve first 1     .nextelementsibling();  // element that's next 

documentation: http://jsoup.org/cookbook/extracting-data/selector-syntax


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -