title: Reading multiple child nodes of xml file
body: <p>I have created an Xml file with example contents as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Periods&gt;
    &lt;PeriodGroup name="HER"&gt;
      &lt;Period&gt;
        &lt;PeriodName&gt;Prehistoric&lt;/PeriodName&gt;
        &lt;StartDate&gt;-500000&lt;/StartDate&gt;
        &lt;EndDate&gt;43&lt;/EndDate&gt;
      &lt;/Period&gt;
      &lt;Period&gt;
        &lt;PeriodName&gt;Iron Age&lt;/PeriodName&gt;
        &lt;StartDate&gt;-800&lt;/StartDate&gt;
        &lt;EndDate&gt;43&lt;/EndDate&gt;
      &lt;/Period&gt;
      &lt;Period&gt;
        &lt;PeriodName&gt;Roman&lt;/PeriodName&gt;
        &lt;StartDate&gt;43&lt;/StartDate&gt;
        &lt;EndDate&gt;410&lt;/EndDate&gt;
      &lt;/Period&gt;
    &lt;/PeriodGroup&gt;
    &lt;PeriodGroup name="CAFG"&gt;
      &lt;Period&gt;
        &lt;PeriodName&gt;Prehistoric&lt;/PeriodName&gt;
        &lt;StartDate&gt;-500000&lt;/StartDate&gt;
        &lt;EndDate&gt;43&lt;/EndDate&gt;
      &lt;/Period&gt;
      &lt;Period&gt;
        &lt;PeriodName&gt;Roman&lt;/PeriodName&gt;
        &lt;StartDate&gt;43&lt;/StartDate&gt;
        &lt;EndDate&gt;410&lt;/EndDate&gt;
      &lt;/Period&gt;
      &lt;Period&gt;
        &lt;PeriodName&gt;Anglo-Saxon&lt;/PeriodName&gt;
        &lt;StartDate&gt;410&lt;/StartDate&gt;
        &lt;EndDate&gt;800&lt;/EndDate&gt;
      &lt;/Period&gt;   
    &lt;/PeriodGroup&gt;
  &lt;/Periods&gt;
  </code></pre>
  
  <p>I need to be able to read the Period node children within a selected PeriodGroup. I guess the PeriodName could be an attribute of Period if that is more sensible.</p>
  
  <p>I have looked at loads of examples but none seem to be quite right and there seems to be dozens of different methods, some using XmlReader, some XmlTextReader and some not using either. As this is my first time reading an Xml file, I thought I'd ask if anyone could give me a pointer. I've got something working just to try things out, but it feels clunky. I'm using VS2010 and c#. Also, I see a lot of people are using LINQ-Xml, so I'd appreciate the pros and cons of using this method. </p>
  
  <pre><code>string PG = "HER";
  XmlDocument doc = new XmlDocument();
  doc.Load(Server.MapPath("./Xml/XmlFile.xml"));
  string text = string.Empty;
  XmlNodeList xnl = doc.SelectNodes("/Periods/PeriodGroup");
  foreach (XmlNode node in xnl)
  {
      text = node.Attributes["name"].InnerText;
      if (text == PG)
      {
          XmlNodeList xnl2 = doc.SelectNodes("/Periods/PeriodGroup/Period");
          foreach (XmlNode node2 in xnl2)
          {
              text = text + "&lt;br&gt;" + node2["PeriodName"].InnerText;
              text = text + "&lt;br&gt;" + node2["StartDate"].InnerText;
              text = text + "&lt;br&gt;" + node2["EndDate"].InnerText;
          }
      }
      Response.Write(text);
  }
  </code></pre>