title: Parsing html with rails and nokogiri
body: <p>I need to parse HTML using Rails and Nokogiri. Here is the HTML:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;body&gt;
    &lt;div id="mama"&gt;
      &lt;div class="test1"&gt;text&lt;/div&gt;
      &lt;div class="test2"&gt;text2&lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="mama"&gt;
      &lt;div class="test1"&gt;text&lt;/div&gt;
      &lt;div class="test2"&gt;text2&lt;/div&gt;
    &lt;/div&gt;
    &lt;div id="mama"&gt;
      &lt;div class="test1"&gt;text&lt;/div&gt;
      &lt;div class="test2"&gt;text2&lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>How I should form loop question? I've tried so many times but still getting an error or bad results...
  ...</p>
  
  <pre><code>doc.xpath('//div[@id='mama']/?or what?').each do |node|
    parse_file.puts text1 
    parse_file.puts text2
    parse_file.puts text1 
    parse_file.puts \n
  end
  </code></pre>
  
  <p>Result should be like</p>
  
  <pre class="lang-none prettyprint-override"><code>text from first mama
  text2 from first mama
  text from first mama
  
  text from second mama
  and so on...
  </code></pre>