My below code is working fine. But can the same output be achieved with
some a more compact CSS selectors?


require 'nokogiri'

doc = Nokogiri::HTML::Document.parse <<-end
<div id="myelement">
    <table class="myclass">
       <tbody>
           <tr>
               <td>something</td>
               <td>
                   <table>
                       <tbody>
                         <tr> hari </tr>
                       </tbody>
                   </table>
               </td>
           </tr>
           <tr>
              foo
           </tr>
       </tbody>
    </table>
</div>
end

nodeset = doc.css("table")
nodeset.css("tbody:nth-child(1)").map{|n| n.css('>tr').to_a.size}
# => [2, 1]

-- 
Posted via http://www.ruby-forum.com/.