Can't return an XML formatted string, using stringbuilder in C# and a DB Template, For a PlaceHolder
<p>Good Afternoon,</p>

<p>I have a function that builds a string for a template in my DB that outputs an XML structure. It takes in a Order class as a parameter and a Template, well I am having troubles trying to populate a placeholder tag named [[items]], where based on the number of items in the table it should build the xml list for that portion. </p>

<p>This is the Template, It is only returning one instance of the string but it should return (n) instances based on what's in the table.</p>

<pre><code>&lt;Items&gt;
   [[items]]
&lt;/Items&gt;
</code></pre>

<p>This is what should be populated for the other tags for the item</p>

<pre><code>&lt;Item&gt;
 &lt;SKU&gt;[[item_sku]]&lt;/SKU&gt;
 &lt;PROD_NAME&gt;&lt;![CDATA[[[item_product_name]]]]&gt;&lt;/PROD_NAME&gt;
 &lt;Description&gt;&lt;![CDATA[[[item_name]]]]&gt;&lt;/Description&gt;
 &lt;Attributes&gt;&lt;![CDATA[[[item_attributes]]]]&gt;&lt;/Attributes&gt;
 &lt;Quantity&gt;[[item_qty]]&lt;/Quantity&gt;
 &lt;UnitPrice&gt;[[item_price]]&lt;/UnitPrice&gt;
 &lt;InkColor&gt;[[item_inkcolor]]&lt;/InkColor&gt;
&lt;/Item&gt;
</code></pre>

<p>And It want to populate like this</p>

<pre><code>&lt;Items&gt;
  &lt;Item&gt;
    &lt;SKU&gt;7Z-BRPA-K79A&lt;/SKU&gt;
    &lt;PROD_NAME&gt;&lt;![CDATA[Test One]]&gt;&lt;/PROD_NAME&gt;
    &lt;Description&gt;&lt;![CDATA[ExcelMark 5-Line Large Return Address Stamp - Custom Self Inking Rubber Stamp]]&gt;&lt;/Description&gt;
    &lt;Attributes&gt;&lt;![CDATA[Custom Text Line 1 Text: This book was donated to CAEO Font: Arial
                Custom Text Line 2 Text: In tribute to &amp; memory of Font: Arial]]&gt;&lt;/Attributes&gt;
    &lt;Quantity&gt;1&lt;/Quantity&gt;
    &lt;UnitPrice&gt;&lt;![CDATA[$9.99]]&gt;&lt;/UnitPrice&gt;
    &lt;InkColor&gt;Red&lt;/InkColor&gt;
  &lt;/Item&gt;
  &lt;Item&gt;
    &lt;SKU&gt;42A1848&lt;/SKU&gt;
    &lt;PROD_NAME&gt;&lt;![CDATA[Test Two]]&gt;&lt;/PROD_NAME&gt;
    &lt;Description&gt;&lt;![CDATA[Self Inking Rubber Stamp with up To 4 Lines of Custom Text]]&gt;&lt;/Description&gt;
    &lt;Attributes&gt;&lt;![CDATA[Custom Text Line 1 Text: This book was donated to CAEO Font: Arial
                Custom Text Line 2 Text: In tribute to &amp; memory of Font: Arial]]&gt;&lt;/Attributes&gt;
    &lt;Quantity&gt;1&lt;/Quantity&gt;
    &lt;UnitPrice&gt;&lt;![CDATA[$8.99]]&gt;&lt;/UnitPrice&gt;
    &lt;InkColor&gt;Blue&lt;/InkColor&gt;
  &lt;/Item&gt;
&lt;/Items&gt;
</code></pre>

<p>Here is the function to make it happen</p>

<pre><code>public string PopulateStringBuilder(Order order, Template template)
    {
        var i = new StringBuilder(template.Description);
        List&lt;string&gt; s = new List&lt;string&gt;();
        var reqID = order.OrderId;

            foreach (var x in order.Items)
            {
                i.Replace("[[item_sku]]", x.SkuNumber);
                i.Replace("[[item_product_name]]", x.ProductName);
                i.Replace("[[item_name]]", x.Description);
                i.Replace("[[item_attributes]]", x.Attributes);
                i.Replace("[[item_qty]]", x.Quantity.ToString());
                i.Replace("[[item_price]]", x.UnitPrice.ToString());
                i.Replace("[[item_inkcolor]]", x.InkColor);
                o.Replace("[[items]]", i.ToString());
            }  
        return o.ToString();
    }
</code></pre>