title: How to filter array with Nokogiri (search, filter, conditions etc)
body: <p>I have an XML document which I need to parse with Nokogiri however I need to filter out all 'role' nodes which names do not match those requested. </p>
  
  <p>Essentially I want to return an array of only those <em>roles</em> where the first and last name match those required.</p>
  
  <p><em>Current Status:</em></p>
  
  <p>I have all the code working except for the one filtering/search line from within the controller. I have had a look through the <em>filter</em> and <em>search</em> functions of Nokogiri but cannot seem to achieve the desired result.</p>
  
  <p><strong>XML Input</strong></p>
  
  <pre><code>&lt;xml&gt;
  &lt;role xsi:type="director"&gt; 
   &lt;firstName&gt;Thomas&lt;/firstName&gt; 
   &lt;lastName&gt;JONES&lt;/lastName&gt;
   &lt;company&gt;Jones Enterprises&lt;/company&gt;
  &lt;/role&gt;
  &lt;role xsi:type="director"&gt; 
   &lt;firstName&gt;Thomas&lt;/firstName&gt; 
   &lt;lastName&gt;TEST&lt;/lastName&gt;
   &lt;company&gt;Test Factory&lt;/company&gt;
  &lt;/role&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>firstname = 'Thomas'
  lastname = 'JONES'
  
  @results = doc.css('role').where((doc.css('firstName').text == @firstname) AND (doc.css('lastName').text == @lastname))
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%= @results.each do |t| %&gt;
    &lt;%= t.company %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>Required Output</strong></p>
  
  <pre><code>Jones Enterprises
  </code></pre>