title: Reading the XML file in c#
body: <p>I have the following XML file (parse.xml):</p>
  
  <pre><code>&lt;Invoice&gt;
      &lt;InvoiceHeader&gt;
            &lt;Name&gt;cust1&lt;/Name&gt;
            &lt;Number&gt;5689&lt;/Number&gt;
      &lt;/InvoiceHeader&gt;
      &lt;InvoiceHeader&gt;
            &lt;Name&gt;cust1&lt;/Name&gt;
            &lt;Number&gt;5689&lt;/Number&gt;
            &lt;Number&gt;5459&lt;/Number&gt;
      &lt;/InvoiceHeader&gt;
  &lt;InvoiceHeader&gt;
            &lt;Name&gt;cust1&lt;/Name&gt;
            &lt;Number&gt;5689&lt;/Number&gt;
            &lt;Number&gt;5645&lt;/Number&gt;
            &lt;Number&gt;5879&lt;/Number&gt;
      &lt;/InvoiceHeader&gt;
  &lt;/Invoice&gt;
  </code></pre>
  
  <p>I would like to read it into a list of the following class:</p>
  
  <pre><code>public class Details    
  {
     public string Name {get; set;}
     public List&lt;string&gt; Number{get; set;}
  }
  </code></pre>
  
  <p>As you can see, in the XML the node <code>Number</code> can appear more than one time in <code>InvoiceHeader</code>.  I'm not sure how to parse this XML into the <code>List&lt;Details&gt;</code> class.</p>
  
  <p>I tried my code: </p>
  
  <pre><code> List&lt;Details&gt; details = new List&lt;Details&gt;;
   XmlDocument doc = new XmlDocument();
   doc.Load("parse.xml");
   XmlNodeList nodeList = doc.SelectNodes("/Invoice/InvoiceHeader");
  
   foreach (XmlNode node in nodeList)
   {
       details.Add(node["Name"].InnerText);
       XmlNodeList dd = node.ChildNodes;
  
       foreach (XmlNode inch in dd)
       {
           details.Add(node["Number"].InnerText);
       }        
  }
  
  </code></pre>
  
  <p>I know this code isn't right but wanted to show what I have done so far.</p>