title: How to get parent's text using Nokogiri
body: <p>I have situation where I want to get a parent <code>&lt;p&gt;</code> tag's text. For example:</p>
  
  <pre><code>&lt;p&gt;
    &lt;a name="TOPIC"&gt;&lt;/a&gt;
    &lt;b&gt;&lt;font color="#800000" size="4" face="Arial"&gt;Exapmles&lt;/font&gt;&lt;/b&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>This is working fine for this example:</p>
  
  <pre><code>test = Nokogiri::HTML("row['test']"])
  raw_attributes = test.root.css("p a").inject({}) do |accumulator, element| 
    accumulator[element.attr("name")] = (element.parent.text).strip
    accumulator
  end
  </code></pre>
  
  <p>But it's not working for the following example:</p>
  
  <pre><code>&lt;p&gt;
    &lt;font&gt;
      &lt;a name="TOPIC"&gt;&lt;/a&gt;
      &lt;b&gt;&lt;font color="#800000" size="4" face="Arial"&gt;Exapmles&lt;/font&gt;&lt;/b&gt;
    &lt;/font&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>How can I do this using Nokogiri? I want the solution which works for both of the above two conditions.</p>