title: How the XmlReader works in C#
body: <p>I'm trying to read some Xml from a string I made, but really any Xml file would be ok.</p>
  
  <p>I just want to browse the Xml nodes like it's a multidimensional matrix and eventually put them in a DataTable (to put them in a sql server with SqlBulkCopy). I've already looked in MSDN and around here. Could someone explain it plain and simple please?</p>
  
  <p>This is the code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Data;
  using System.Xml;
  using System.IO;
  
  namespace ConsoleApplication2
  {
      class Program
      {
          private static DataTable table = new DataTable();
          private static String xmlString =
          @"&lt;?xml version='1.0'?&gt;
          &lt;!-- This is a sample XML document --&gt;
          &lt;Garage&gt;
              &lt;Car&gt;
                  &lt;Name&gt;Ferrari&lt;/Name&gt;
                  &lt;Speed&gt;360km/h&lt;/Speed&gt;
                  &lt;Engine&gt;Ferrari Enzo&lt;/Engine&gt;
                  &lt;Color&gt;Red&lt;/Color&gt;
                  &lt;Year&gt;1999&lt;/Year&gt;
              &lt;/Car&gt;
              &lt;Car&gt;
                  &lt;Name&gt;Maserati&lt;/Name&gt;
                  &lt;Speed&gt;270km/h&lt;/Speed&gt;
                  &lt;Color&gt;Metal Grey&lt;/Color&gt;
                  &lt;Year&gt;2007&lt;/Year&gt;
              &lt;/Car&gt;
              &lt;Car&gt;
                  &lt;Name&gt;Limo&lt;/Name&gt;
                  &lt;Color&gt;Black&lt;/Color&gt;
                  &lt;Engine&gt;Chevrolet&lt;/Engine&gt;
                  &lt;Year&gt;2007&lt;/Year&gt;
              &lt;/Car&gt;
          &lt;/Garage&gt;";
  
          static void Main(string[] args)
          {
              Program x = new Program();
              XmlReader reader = XmlReader.Create(new StringReader(xmlString));
              while (reader.Read())
              {
                  if (reader.NodeType == XmlNodeType.Element)
                  {
                      Console.WriteLine(XmlNodeType.Element.ToString());
                      }
                  }
              }
  
          }
      }
  </code></pre>
  
  <p>I would like to loop the whole thing and get something like:</p>
  
  <p>Name: Ferrari
  Speed: 360km/h
  Engine: Ferrari Enzo</p>
  
  <p>and so on, you got the drill.</p>