Note that there are some explanatory texts on larger screens.

plurals
  1. POJSOUP select all text following a closing tag until a specified tag
    text
    copied!<p>I have this html amongst a lot of table rows in a table:</p> <pre><code>......... &lt;tr class="greycellodd" align="right"&gt; &lt;td align="left"&gt; &lt;input type="checkbox" name="cashInvestment" value="100468057"/&gt; &lt;/td&gt; &lt;td align="left"&gt;Cardcash &lt;/td&gt; &lt;td class="nobr"&gt;26 Aug 10&lt;/td&gt; &lt;td class="nobr"&gt; 1.00 &lt;/td&gt; &lt;td class="nobr"&gt; 1.00 &lt;/td&gt; &lt;td align="right"&gt;£&lt;/td&gt; &lt;td class="nobr"&gt;0.00 &lt;/td&gt; &lt;td class="nobr"&gt;0.00 &lt;/td&gt; &lt;td class="nobr"&gt; &lt;span class="changeupsmall"&gt;1.00 &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="greycellodd"&gt; &lt;td align="right"/&gt; &lt;td class="nobr" colspan="8"&gt;VISA&lt;/td&gt; &lt;/tr&gt; &lt;tr class="greycelleven" align="right"&gt; &lt;td align="left"&gt; &lt;input type="checkbox" name="cashInvestment" value="100480214"/&gt; &lt;/td&gt; &lt;td align="left"&gt;Santander &lt;/td&gt; &lt;td class="nobr"&gt;24 Sep 11&lt;/td&gt; &lt;td class="nobr"&gt; 1.00 ....... </code></pre> <p>I need to extract everything between each checkbox tag</p> <pre><code>&lt;input type="checkbox" name="cashInvestment" ../&gt; </code></pre> <p>Example</p> <p>Elemtent 1:</p> <pre><code>Cardcash 26 Aug 10 1.00 1.00 £ 0.00 0.00 1.00 VISA </code></pre> <p>Element 2:</p> <pre><code>Santander 24 Sep 11 1.00 ....... </code></pre> <p>I have tried:</p> <pre><code> Elements Inve = mainFirst.select("input ~ *" ); </code></pre> <p>and</p> <pre><code> Elements Inve = doc.select("input"); // gives me nothing as there is no text to the input tag (it has no child). </code></pre> <p>I also need to get the value of the checkbox, which I know how to do, but would be nice to do at the same time if possible:</p> <pre><code>Elements mainTables = doc.select("table.maintable"); for (Element subTable : mainTables){ Elements borrowInve = subTable.select("input[type=checkbox][name=cashInvestment]" ); String attr = test.attr("value"); } </code></pre> <p>Thanks</p> <p>Edit: resolved by checking the size :</p> <pre><code> Elements td = tableRows.get(i).select("td"); Elements cash = tableRows.get(i).getElementsByAttributeValue("name", attrValue); // check if checkbox is present int theSize = cash.size(); if(theSize ==1){ // this row is not a comment String checkbox = ""; Element cbox = td.select("input[type=checkbox]" ).first(); checkbox = cbox.attr("value"); else if (theSize ==0){ // this row contains a comment ............. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload