title: how to read nested elements using Linq to xml
body: <p>I am trying to read the nested elements in the xml below. So far I have been able to read data in <code>chantier/data</code> element, but now the problem lies in how can I read the data inside <code>&lt;questions&gt;&lt;sitePreparation&gt; and &lt;ctm&gt;</code>? Xml file and code have been shorted a bit because they are too long. Any help is much appreciated.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Audit&gt;
      &lt;controls&gt;
          &lt;guid&gt;
             0001
          &lt;/guid&gt;
          &lt;templateVersion&gt;
                      1.0
          &lt;/templateVersion&gt;
      &lt;/controls&gt;
      &lt;chantier&gt;
          &lt;data&gt;
              &lt;V2&gt;V2&lt;/V2&gt;
              &lt;V3&gt;V3&lt;/V3&gt;
              &lt;V3_1&gt;V3_1&lt;/V3_1&gt;
              &lt;V4&gt;V4&lt;/V4&gt;
              &lt;oresTiersPanel&gt;
                  &lt;S1_2&gt;S1_2&lt;/S1_2&gt;
              &lt;/oresTiersPanel&gt;
              &lt;agentsTiersPanel&gt;
                  &lt;S1_2_2&gt;S1_2_2&lt;/S1_2_2&gt;
              &lt;/agentsTiersPanel&gt;
          &lt;/data&gt;
          &lt;questions&gt;
              &lt;sitePreparation&gt;
                  &lt;P1_Question&gt;P1_Q&lt;/P1_Question&gt;
                  &lt;P6_Question&gt;P6_Q&lt;/P6_Question&gt;
              &lt;/sitePreparation&gt;
              &lt;ctm&gt;
                  &lt;C1_Question&gt;C1_Q&lt;/C1_Question&gt;
                  &lt;C2_Question&gt;C2_Q&lt;/C2_Question&gt;
                  &lt;C2_1&gt;C2_1&lt;/C2_1&gt;
              &lt;/ctm&gt;
          &lt;/questions&gt;
      &lt;/chantier&gt;
  &lt;/Audit&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>private static void ReadXml()
  {
      XDocument xdoc = XDocument.Load("sipp.xml");
  
      if (xdoc.Root != null)
      {
          var chantier = from ch in xdoc.Root.Elements("chantier").Elements("data")
                         let agentsTiersPanel = ch.Element("agentsTiersPanel")
                         where agentsTiersPanel != null
                         select new
              {
                  v2 = (string)ch.Element("V2"),
                  v3 = (string)ch.Element("V3"),
                  v3_1 = (string)ch.Element("V3_1"),
                  v4 = (string)ch.Element("V4"),
                  S1_2_2 = (string)agentsTiersPanel.Element("S1_2_2"),
                  S1_2_2_1 = (string)agentsTiersPanel.Element("S1_2_2_1"),
                  S1_2_3 = (string)agentsTiersPanel.Element("S1_2_3"),
                  S3 = (string)ch.Element("S3"),
                 S3_1 = (string)ch.Element("S3_1"),
                  P1_Question = (string)ch.Element("P1_Question")
              };
  
          foreach (var item in chantier)
          {
              Console.WriteLine(item.v2 + " " + item.v3);
          }
      }
  }
  </code></pre>