title: Filtering XML elements with null attributes
body: <p>I'm trying to extract attributes from a regular XML structure; it seems natural to first exclude the elements for which a particular attribute is missing.</p>
  
  <p>I don't know why the following doesn't work (see answer for why I ever got the idea to test vs. <code>null</code>):</p>
  
  <pre><code>val test = &lt;top&gt;&lt;el attr="1"&gt;&lt;/el&gt;&lt;el&gt;&lt;/el&gt;&lt;el attr="2"&gt;&lt;/el&gt;&lt;/top&gt;
  test.child.filter(_ \ "@attr" != null).map(_ \ "@attr")
  // ArrayBuffer(1, NodeSeq(), 2)
  </code></pre>
  
  <p>Why is the middle element still there after the <code>filter</code>?</p>
  
  <p>I've confirmed it's not operator precedence:</p>
  
  <pre><code>test.child.filter(x =&gt; (x \ "@attr") != null).map(_ \ "@attr")
  // ArrayBuffer(1, NodeSeq(), 2)
  </code></pre>
  
  <p>Alternatively (assuming this is optimized internally), how could I exclude the <code>NodeSeq()</code> elements <em>after</em> the <code>map</code> step?</p>