title: Simple Linq to XML Query Doesn't Work
body: <p>I nominate me for village idiot.</p>
  
  <p>Why doesn't this work:</p>
  
  <pre><code>foreach (XElement clientField in _clientXml.Descendants("row").Descendants())
  {
      var newFieldName =
          from sourceField in _sourceEntries.Descendants("Field")
          where (string)sourceField.Attribute("n") == (string)clientField.Attribute("n")
          select new
              {
                  FieldName = ((string) sourceField.Attribute("n")),
                  AcordRef = ((string) sourceField.Attribute("m"))
               };
          foreach (var element in newFieldName)
          {
              Console.WriteLine("Field Name: {0}", 
              element.FieldName, element.AcordRef);
          }
  }
  </code></pre>
  
  <p>My source XML files are loaded with XElement.Load(myFileName). In debug, clientField has an attribute n="Policy Number". The first element of _sourceEntries.Descendants("Field") also has an attribute n="Policy Number". Indeed, each element in _clientXml.Descendants("row").Descendants() has a matching row in _sourceEntries.Descendants("Field"). And, I know just enough to know that the select is lazy, so in debug I look at the Console.WriteLine block. No matter what I've tried, newFieldName is an empty set. </p>
  
  <p>Just in case, here's the first element of the client file:</p>
  
  <pre><code>&lt;Column_0 n="Policy Number"&gt;ABC000123&lt;/Column_0&gt;
  </code></pre>
  
  <p>And, here's the fist element of the _sourceEntries collection:</p>
  
  <pre><code>&lt;Field n="Policy Number" c="1" l="" s="" cd="" m="1805" f="" /&gt;
  </code></pre>
  
  <p>I know it's going to be something simple, but I just don't see what I'm doing wrong. </p>
  
  <p>Thanks.</p>
  
  <p>Randy</p>