title: XElement.element() returns null sometimes
body: <p>I'm loading an XML file, getting the values of some nodes and then setting those values into an object.</p>
  
  <p>The problem is that although I can get into the each node, I can't get its value: it just returns null.  Searching in Google and SO I found several threads saying that usually it is a problem of namespaces.  So I set up a namespace on the XML file and in my code to work with it.  This is now when things get funny: </p>
  
  <ul>
  <li>If all the nodes but the last one are prefixed (in my code) with the namespace, all of them gets set except that particular one which gives an ArgumentNullException (<code>tabla</code> does not accept nulls on some properties).  This seems to be expected behavior.</li>
  <li>if I correct that last line and set up the namespace (as it should be), then the exception gets raised at the FIRST node.</li>
  </ul>
  
  <p>This is the XML:
  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;root xmlns="http://daniel.ponticelli.com/ns/dataExport"&gt;
    &lt;PollInstance&gt;
      &lt;Poll_Instance_id&gt;1&lt;/Poll_Instance_id&gt;
      &lt;POLL_description&gt;Mes 1&lt;/POLL_description&gt;
      &lt;dt_start&gt;01/09/2012 12:00:00 a.m.&lt;/dt_start&gt;
      &lt;dt_end&gt;30/09/2012 12:00:00 a.m.&lt;/dt_end&gt;
      &lt;POLL_status&gt;0&lt;/POLL_status&gt;
      &lt;dt_created&gt;03/09/2012 09:50:36 a.m.&lt;/dt_created&gt;
      &lt;dt_updated&gt;03/09/2012 09:50:36 a.m.&lt;/dt_updated&gt;
      &lt;id_original_clone&gt;0&lt;/id_original_clone&gt;
      &lt;target_locs&gt;0&lt;/target_locs&gt;
      &lt;id_poll&gt;1&lt;/id_poll&gt;
    &lt;/PollInstance&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>This is the "wrong" code that has the last element without namespace:
  </p>
  
  <pre><code>XElement instancia = xml.Descendants().First();
  XNamespace ra = "http://daniel.ponticelli.com/ns/dataExport";
  
  tabla.Poll_Instance_id = (int)instancia.Element(ra + "Poll_Instance_id");
  tabla.POLL_description = (string)instancia.Element(ra + "POLL_description");
  tabla.dt_start = DateTime.Parse((string)instancia.Element(ra + "dt_start"));
  tabla.dt_end = DateTime.Parse((string)instancia.Element(ra + "dt_end"));
  tabla.POLL_status = (int)instancia.Element(ra + "POLL_status");
  tabla.dt_created = DateTime.Parse((string)instancia.Element(ra + "dt_created"));
  tabla.dt_updated = DateTime.Parse((string)instancia.Element(ra + "dt_updated"));
  tabla.id_original_clone = (int)instancia.Element(ra + "id_original_clone");
  tabla.target_locs = (int)instancia.Element(ra + "target_locs");
  tabla.id_poll = (int)instancia.Element("id_poll");
  </code></pre>
  
  <p>The previous code gives the exception on the last line.</p>
  
  <p>Now this is the "correct" code that has all the elements prefixed with the namespace:
  </p>
  
  <pre><code>XElement instancia = xml.Descendants().First();
  XNamespace ra = "http://daniel.ponticelli.com/ns/dataExport";
  
  tabla.Poll_Instance_id = (int)instancia.Element(ra + "Poll_Instance_id");
  tabla.POLL_description = (string)instancia.Element(ra + "POLL_description");
  tabla.dt_start = DateTime.Parse((string)instancia.Element(ra + "dt_start"));
  tabla.dt_end = DateTime.Parse((string)instancia.Element(ra + "dt_end"));
  tabla.POLL_status = (int)instancia.Element(ra + "POLL_status");
  tabla.dt_created = DateTime.Parse((string)instancia.Element(ra + "dt_created"));
  tabla.dt_updated = DateTime.Parse((string)instancia.Element(ra + "dt_updated"));
  tabla.id_original_clone = (int)instancia.Element(ra + "id_original_clone");
  tabla.target_locs = (int)instancia.Element(ra + "target_locs");
  tabla.id_poll = (int)instancia.Element(ra + "id_poll");
  </code></pre>
  
  <p>This code now gives the exception on the third line! (the one that begins with <code>tabla.Poll_Instance_id</code>).  If I set a breakpoint on the "wrong" code just before the last line, I can check in VS that indeed the values are being retrieved from the XML and set on the object <code>tabla</code> as expected; so I don't know what's going on.</p>