title: C# console application: reading data from xml file
body: <p>I am totally new to reading data from file, specially xml files.
  I have a xml file in my <code>bin\debug</code> folder and the xml file looks something like this:</p>
  
  <pre><code>&lt;Companies&gt;
      &lt;Company&gt;
          &lt;Name&gt;Name1&lt;/Name&gt;&lt;Code&gt;11014&lt;/Code&gt;    
          &lt;MaintenancePercentage&gt;15.9&lt;/MaintenancePercentage&gt;
          &lt;Sales&gt;
              &lt;Sale&gt;
                  &lt;Code&gt;19538&lt;/Code&gt;
                  &lt;Title&gt;ABC&lt;/Title&gt;
                  &lt;Date&gt;2009-04-29T00:00:00&lt;/Date&gt;
                  &lt;Category&gt;Category1&lt;/Category&gt;
                  &lt;Amount&gt;6543.39&lt;/Amount&gt;
              &lt;/Sale&gt;
              &lt;Sale&gt;
                  &lt;Code&gt;19539&lt;/Code&gt;
                  &lt;Title&gt;xyz&lt;/Title&gt;
                  &lt;Date&gt;2009-04-30T00:00:00&lt;/Date&gt;
                  &lt;Category&gt;Category2&lt;/Category&gt;
                  &lt;Amount&gt;654.39&lt;/Amount&gt;
              &lt;/Sale&gt;
          &lt;/Sales&gt;
      &lt;/Company&gt;
  
      &lt;Company&gt;
          &lt;Name&gt;Name1&lt;/Name&gt;&lt;Code&gt;11014&lt;/Code&gt;     
          &lt;MaintenancePercentage&gt;15.9&lt;/MaintenancePercentage&gt;
          &lt;Sales&gt;
              &lt;Sale&gt;
                  &lt;Code&gt;19538&lt;/Code&gt;
                  &lt;Title&gt;ABC&lt;/Title&gt;
                  &lt;Date&gt;2009-04-29T00:00:00&lt;/Date&gt;
                  &lt;Category&gt;Category1&lt;/Category&gt;
                  &lt;Amount&gt;6543.39&lt;/Amount&gt;
              &lt;/Sale&gt;
              &lt;Sale&gt;
                  &lt;Code&gt;19539&lt;/Code&gt;
                  &lt;Title&gt;xyz&lt;/Title&gt;
                  &lt;Date&gt;2009-04-30T00:00:00&lt;/Date&gt;
                  &lt;Category&gt;Category2&lt;/Category&gt;
                  &lt;Amount&gt;654.39&lt;/Amount&gt;
              &lt;/Sale&gt;
          &lt;/Sales&gt;
      &lt;/Company&gt;
  &lt;/Companies&gt;
  </code></pre>
  
  <p>This are my classes:</p>
  
  <pre><code>public class Company
  {
      public string Name;
      public string Code;
      public double MaintenancePercentage;
      public double AverageSales;
      public double TotalSales;
      public double TotalMaintenanceFee;
      public List&lt;Sales&gt; Saleses;
  
  }
  public class Sales
  {
      public string Code;
      public string Title;
      public DateTime DateTime;
      public string Category;
      public double Amount;
  }
  </code></pre>
  
  <p>Now from the xml file I want to read the data and store them.</p>
  
  <p>How can I read the values from the xml files?</p>
  
  <p>For example</p>
  
  <pre><code>var company = new Company();
  company.Name = //name from xml file
  //and so on
  foreach(sales in company)
  {
     sales.code = //code from xml file
     sales.title = //title from xml file
     //and so on
  }
  </code></pre>
  
  <p>This is what I've done so far using search results from google, but I don't know what to do now</p>
  
  <pre><code>var doc = new XmlDocument();
  doc.Load(@"export.xml");
  var root = doc.DocumentElement;
  if (root == null)
  {
      return;
  }
  var company = root.SelectNodes("Company");
  if (company == null)
  {
      return;
  }
  else
  {
      foreach (var companyData in company)
      {
          var title = 
      }
  }
  </code></pre>
  
  <p>This last piece of code makes any sense at least?</p>