title: How to get Nokogiri to ignore HTML elements that doesn't exist
body: <p>any idea how i can get the code below to produce this output?</p>
  
  <p>1 -<br>
  2 - B</p>
  
  <p>i'm getting this error "undefined method `text' for nil:NilClass (NoMethodError)", because i think table 1 does not have the element 'td class=r2' in it.</p>
  
  <pre><code>require 'rubygems'  
  require 'nokogiri'  
  require 'open-uri'
  
  doc = Nokogiri::HTML.parse(&lt;&lt;-eohtml)
  &lt;table class="t1"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td class="r1"&gt;1&lt;/td&gt;
          &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;table class="t2"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td class="r1"&gt;2&lt;/td&gt;
              &lt;td class="r2"&gt;B&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;            
  &lt;/table&gt;  
  eohtml
  
  doc.css('tbody &gt; tr').each do |n|
      r1 = n.at_css(".r1").text
      r2 = n.at_css(".r2").text
      puts "#{r1} - #{r2}"
  end
  </code></pre>