title: Nested foreach loop reading .xml and writing object to list
body: <p>I have a method that executes upon form_load event that seems to work properly omitting one line.</p>
  
  <pre><code>private int ReadInPeople()
  {
      XmlNodeList nodeList = m_xmlDoc.DocumentElement.ChildNodes;
      foreach (XmlNode PersonNode in nodeList)
      {
          Employee ccontact = new Employee();
          foreach (XmlNode PersonTag in PersonNode.ChildNodes)
          {
              switch (PersonTag.Name)
              {
                  case "Employee":
                      ccontact.EmployeeNumber = PersonTag.FirstChild.Value;
                      break;
                  case "FirstName":
                      ccontact.FirstName = PersonTag.FirstChild.Value;
                      break;
                  case "LastName":
                      ccontact.LastName = PersonTag.FirstChild.Value;
                      break;
                  default:
                      break;
              }
          }
          this.AddContact(ccontact);
      }
      return nodeList.Count;
  }
  </code></pre>
  
  <p>The AddContact method adds the Employee object to a static list; however, the line:</p>
  
  <pre><code>this.AddContact(ccontact);
  </code></pre>
  
  <p>was not being executed.</p>
  
  <p>A sample of the XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;people&gt;
    &lt;person&gt;
      &lt;Employee&gt;123456789&lt;/Employee&gt;
      &lt;FirstName&gt;John&lt;/FirstName&gt;
      &lt;LastName&gt;Smith&lt;/LastName&gt;
    &lt;/person&gt;
    &lt;person&gt;
      &lt;Employee&gt;987654321&lt;/Employee&gt;
      &lt;FirstName&gt;Ellen&lt;/FirstName&gt;
      &lt;LastName&gt;Wayne&lt;/LastName&gt;
    &lt;/person&gt;
  &lt;/people&gt;
  </code></pre>
  
  <p>I had tried setting a breakpoint and debugging, and sure enough, the line was skipped over completely as if it were not even there.</p>
  
  <p>As per Alan's advice, I changed the PersonTag.FirstChild.Value as it was attempting to reference a ChildNode that did not exist.</p>
  
  <p>The updated, working method:</p>
  
  <pre><code>private int ReadInPeople()
  {
      XmlNodeList nodeList = m_xmlDoc.DocumentElement.ChildNodes;
      foreach (XmlNode PersonNode in nodeList)
      {
          Employee ccontact = new Employee();
          foreach (XmlNode PersonTag in PersonNode.ChildNodes)
          {
              switch (PersonTag.Name)
              {
                  case "Employee":
                      ccontact.EmployeeNumber = PersonTag.InnerText;
                      break;
                  case "FirstName":
                      ccontact.FirstName = PersonTag.InnerText;
                      break;
                  case "LastName":
                      ccontact.LastName = PersonTag.InnerText;
                      break;
                  default:
                      break;
              }
          }
          this.AddContact(ccontact);
      }
      return nodeList.Count;
  }
  </code></pre>