title: C# Parsing simple XML file with LINQ
body: <p>I have this very simple xml file :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ConfigurationFile&gt;
      &lt;ConfigurationFilePath&gt;Test1&lt;/ConfigurationFilePath&gt;
      &lt;ConnectionString&gt;Test2&lt;/ConnectionString&gt;
      &lt;AnalyzeFilePath&gt;Test3&lt;/AnalyzeFilePath&gt;
  &lt;/ConfigurationFile&gt;
  </code></pre>
  
  <p>And I want to get informations of each field.
  But this doesn't display anything..</p>
  
  <p>Here is my C# code behind :</p>
  
  <pre><code>private void ParseXMLFile()
  {
      Console.WriteLine("Parse");
      if (configurationPAthFileTextbox.Text != null)
      {
          Console.WriteLine("file != null");
          try
          {
              XElement main = XElement.Load(configurationPAthFileTextbox.Text);
  
              var results = main.Descendants("ConfigurationFile")
                            .Select(e =&gt; new { ConfigurationFilePath = e.Descendants("ConfigurationFilePath").FirstOrDefault().Value,
                                     ConnectionString = e.Descendants("ConnectionString").FirstOrDefault().Value });
  
              foreach (var result in results)
                  Console.WriteLine("{0}, {1}", result.ConfigurationFilePath, result.ConnectionString);
              Console.ReadLine();
  
          }
          catch (Exception e)
          {
              Debug.WriteLine(e.ToString());
          }
      }
  }
  </code></pre>