title: Using XML to populate dynamic datagridview
body: <p>I have an XML file that needs to be populate two columns in my datagridview. I've never worked with XML before but I've gotten it to where I can change the "data" part to whatever I want through a textbox and button. Now I need it to where I can have the "Child1" be placed into one column called "Name" and the "data" part into another column right beside the first called "Value". Also, I'm creating the datagridview at runtime and I eventually want this tool to be able to dynamically change depending on the xml file that has been read.</p>
  
  <p>
  Top Element</p>
  
  <pre><code>&lt;Child1&gt;data&lt;/Child1&gt;
  
  &lt;Child2&gt;data&lt;/Child2&gt;
  
  &lt;Child3&gt;data&lt;/Child3&gt;
  
  &lt;Child4&gt;data&lt;/Child4&gt;
  </code></pre>
  
  <p>/TopElement
  </p>
  
  <p>I've tried using both the system.XML and system.XML.Linq and I just can't seem to be able to populate the datagridview columns with what I need. My dataSet adds two columns to my datagridview and only one row, both are not what I want.</p>
  
  <pre><code>try
  {
     xmlReader xmlFile;
     xmlFile = XmlReader.Create(@"C:location\dataFile.xml", new XmlReaderSettings());
     DataSet ds = new DataSet();
     ds.ReadXml(@"C:location\datafile.xml");
     dgv_XML.DataSource = ds.Tables[0];
  }
  catch (Exception ex)
  {
     MessageBox.Show(ex.ToString());
  }
  </code></pre>
  
  <p>I tried to get all of the rows with a foreach loop as well, but it only crashes my program.</p>
  
  <pre><code>foreach (XNode name_node in TopElement.Nodes())
  {
     dgv_XML.Rows.Insert(0,1);
  }
  </code></pre>