title: XML: XElement.Parse is Throwing an Exception
body: <p>I've got a list of xml strings that I need to parse and load into a c# class.  I'm getting null reference exceptions and think the "root" cause of it are the namespaces used in the xml.  I'm not well versed in ling to xml, so please offer alternatives if this solution looks bad.</p>
  
  <p>Here's the parsing code:</p>
  
  <pre><code>XNamespace ns = "http://www.example.com/schema/msc/message";
  XNamespace ns2 = "http://www.example.com/schema/msc/referral";
  
  // data is List&lt;string&gt;
  Parallel.ForEach(data, item =&gt;
  {
     var root = XElement.Parse(item);
     var dto = new DTO
         {
           RoutingCode = (string)root.Element("Message")
                 .Element(ns + "Params")
                 .Element(ns + "Events")
                 .Attribute("Code")
           User = new UserDTO
                      {
                       AccountName = (string)root.Element("Message")
                                    .Element("Params")
                                    .Element("Events")
                                    .Element("ref:User")
                                    .Element("Name")
                      }
         };
       list.Add(dto);
  });
  </code></pre>
  
  <p>Here's a sample xml element (reduced in size for readability)</p>
  
  <pre><code>&lt;Message xmlns="http://www.example.com/schema/msc/message"&gt;
    &lt;Params&gt; 
      &lt;Events xmlns="http://www.example.com/schema/msc/referral" Code="AC"&gt;
        &lt;ref:User xmlns:ref="http://www.example.com/schema/msc/referral" Name="asdf"/&gt;
      &lt;/Events&gt;
    &lt;/Parama&gt;
  &lt;/Message&gt;
  </code></pre>