title: InfoPath 2010: Trouble programmatically adding rows to a repeating table/section that is nested within a repeating table
body: <p>I have a repeating table nested within a repeating table. The nested table contains 5 columns, 1 for the year, 4 for the different quarters (financial). I need to dynamically add rows to the nested table if the project lasted longer than one year. So if the project lasted 2 years, I would need to add 2 rows in the nested table and fill it with data, if it lasted 3 years, I would need to add 3, etc..</p>
  
  <p>I can't seem to get the nested table to populate with any data. I am using a loop with an outside XmlWriter for the first table, and a nested XmlWriter for the nested table. Here is a code example:</p>
  
  <pre><code>  public void BuildHwSwForecastRow(string vendor, string description, string totalCost, XPathNavigator root)
      {
          string myNameSpace = NamespaceManager.LookupNamespace("my");
  
          using (XmlWriter writer = root.SelectSingleNode ("/my:myFields/my:HW_SW_Other_Forecast/my:Forecasts",NamespaceManager).AppendChild())
          {
              writer.WriteStartElement("Forecast", myNameSpace);
              writer.WriteElementString("HSOF-VendorName", myNameSpace, vendor);
              writer.WriteElementString("HSOF-Description", myNameSpace, description);
              writer.WriteElementString("HSOF-TotalCost", myNameSpace, totalCost);
  
              using (XmlWriter insideWriter = root.SelectSingleNode("//my:HW_SW_Other_Forecast/my:Forecasts/my:Forecast/my:Quarterly_Breakdowns", NamespaceManager).AppendChild())
              {
                  insideWriter.WriteStartElement("Quarterly_Breakdown", myNameSpace);
                  insideWriter.WriteElementString("HSOF-Year", myNameSpace, "2011");
                  insideWriter.WriteElementString("HSOF-Q1", myNameSpace, "");
                  insideWriter.WriteElementString("HSOF-Q2", myNameSpace, "");
                  insideWriter.WriteElementString("HSOF-Q3", myNameSpace, "");
                  insideWriter.WriteElementString("HSOF-Q4", myNameSpace, "");
                  insideWriter.WriteEndElement();
                  insideWriter.Close();
              }
              writer.WriteElementString("HSOF-Total", myNameSpace, "0.0");
              writer.WriteEndElement();
              writer.Close();
          }
      }
  </code></pre>