title: Ruby Nokogiri text search not working with br tags and others
body: <p>I'm using the Nokogiri gem in Ruby and running into some problems. </p>
  
  <p>I want to scrape addresses from webpages and there is no set format to the way the addresses will be displayed.</p>
  
  <p>I've got a list of postcodes and I want my Ruby script to return the node including the postcode so that I can find the rest of the address.</p>
  
  <p>This is what I've got in Ruby, with some example HTML content:</p>
  
  <pre><code>require 'nokogiri'
  require 'open-uri'
  
  content1 = '
  &lt;div&gt;
      &lt;div&gt;
          &lt;div&gt;Our Address:&lt;/div&gt;
          1 North Street
          North Town
          North County
          N21 4DD
      &lt;/div&gt;
  &lt;/div&gt;'
  
  doc = Nokogiri::HTML(content1)
  result = doc.search "[text()*='N21 4DD']"
  puts result.inspect
  </code></pre>
  
  <p>This returns <code>[]</code></p>
  
  <p>I understand the example above is a strange way for an address to appear in HTML but it's the simplest way I can show the problems I've had. Here's another <code>content</code> variable that returns nothing:</p>
  
  <pre><code>content1 = '
  &lt;div&gt;
      &lt;div&gt;Our Address:&lt;/div&gt;
      &lt;div&gt;
          1 North Street&lt;br&gt;
          North Town&lt;br&gt;
          North County&lt;br&gt;
          N21 4DD
      &lt;/div&gt;
  &lt;/div&gt;'
  </code></pre>
  
  <p>I know that Nokogiri might have trouble with the above because the <code>&lt;br&gt;</code> tags should be <code>&lt;/br&gt;</code> but this is quite common on websites.</p>
  
  <p>THIS EXAMPLE WORKS:</p>
  
  <pre><code>content1 = '
  &lt;div&gt;
      &lt;div&gt;Our Address:&lt;/div&gt;
      &lt;div&gt;
          1 North Street
          North Town
          North County
          N21 4DD
      &lt;/div&gt;
  &lt;/div&gt;'
  </code></pre>
  
  <p>Can someone explain why the node is not being found from the first two <code>content</code> examples above and how I can fix this?</p>
  
  <p>I'm not looking for a custom solution that will find the postcode in the sample <code>content</code> examples above – these are just for demonstration purposes. The postcode (and address) could be anywhere in the html – <code>body</code>, <code>p</code>, <code>div</code>, <code>td</code>, <code>span</code>, <code>li</code> etc.</p>
  
  <p>Thanks.</p>