title: c# XML Parsing separating innerxml from innertext
body: <p>What I am trying to do is create ideally a nested List basically a 2d list, or a 2D array if that is better for this task, that would work as follows <code>ID =&gt; 1 Name =&gt; Hickory</code>  without explicitly selecting the node. </p>
  
  <p>I could use SelectNode (Woods/Wood) and then do something like <code>node["ID"].InnerText</code> but that would require that I know what the nodes name is. </p>
  
  <p>Assume that this would read <code>wood.xml</code> even if there were 36 nodes instead of 7 and that I will never know the name of the nodes. I tried using <code>outerxml</code>/<code>innerxml</code> but that gives me too much information.</p>
  
  <pre><code> XmlDocument doc = new XmlDocument();
          doc.Load("wood.xml");
  
          //Here is wood.xml
          /*&lt;Woods&gt;&lt;Wood&gt;&lt;ID&gt;1&lt;/ID&gt;&lt;Name&gt;Hickory&lt;/Name&gt;&lt;Weight&gt;3&lt;/Weight&gt;&lt;Thickness&gt;4&lt;/Thickness&gt;&lt;Density&gt;5&lt;/Density&gt;&lt;Purity&gt;6&lt;/Purity&gt;&lt;Age&gt;7&lt;/Age&gt;&lt;/Wood&gt;&lt;Wood&gt;&lt;ID&gt;2&lt;/ID&gt;&lt;Name&gt;Soft Maple&lt;/Name&gt;&lt;Weight&gt;3&lt;/Weight&gt;&lt;Thickness&gt;4&lt;/Thickness&gt;&lt;Density&gt;5&lt;/Density&gt;&lt;Purity&gt;6&lt;/Purity&gt;&lt;Age&gt;7&lt;/Age&gt;&lt;/Wood&gt;&lt;Wood&gt;&lt;ID&gt;3&lt;/ID&gt;&lt;Name&gt;Red Oak&lt;/Name&gt;&lt;Weight&gt;3&lt;/Weight&gt;&lt;Thickness&gt;4&lt;/Thickness&gt;&lt;Density&gt;5&lt;/Density&gt;&lt;Purity&gt;6&lt;/Purity&gt;&lt;Age&gt;7&lt;/Age&gt;&lt;/Wood&gt;&lt;/Woods&gt;*/
  
  
          XmlNode root = doc.FirstChild;
  
          //Display the contents of the child nodes.
          if (root.HasChildNodes)
          {
              for (int i=0; i&lt;root.ChildNodes.Count; i++)
              {
                  Console.WriteLine(root.ChildNodes[i].InnerXml);
                  Console.WriteLine();
              }
  
              Console.ReadKey();
          }
  </code></pre>
  
  <p>That would allow me to basically create a wood "<strong>buffer</strong>" if you will so I can access these values elsewhere.</p>
  
  <p>Sorry if I was unclear I want to essentially make this "abstract" for lack of a better word.</p>
  
  <p>So that if I were someday to change the name of "Weight" to "HowHeavy" or if i were to add an additional element "NumberOfBranches" I would not have to hardcode the structure of the xml file.</p>