title: How to get the first node prior to the current node that contains text using Nokogiri?
body: <p>I have a node that contains the text <code>'The f'</code>:</p>
  
  <pre><code>&lt;w:r w:rsidR="00BC78BF"&gt;
    &lt;w:t&gt;e takes out his phone and calls a friend.&lt;/w:t&gt;
  &lt;/w:r&gt;
  &lt;w:r w:rsidR="00CB49B6"&gt;
    &lt;w:t xml:space="preserve"/&gt;
  &lt;/w:r&gt;
  &lt;w:ins w:author="Mitchell Gould" w:date="2016-11-14T14:23:00Z" w:id="8"&gt;
    &lt;w:r w:rsidR="00BC7F15"&gt;
      &lt;w:t&gt;The f&lt;/w:t&gt;
    &lt;/w:r&gt;
  &lt;/w:ins&gt;
  </code></pre>
  
  <p>I want to get the first occurrence of text that exists before this text node.</p>
  
  <p>I tried using:</p>
  
  <pre><code> node.previous_element.text
   =&gt; " " 
  </code></pre>
  
  <p>and</p>
  
  <pre><code>previous_node = node.xpath('preceding-sibling::w:r').last
  =&gt; " "
  </code></pre>
  
  <p>This is because sometimes the <code>previous_element</code> is just a space as shown above, and it is possible that there could be many of these elements that are just spaces.</p>
  
  <p>How can I get the first prior sibling that contains text?</p>