I have noticed some code that I wrote a few years back and whilst thinking about optimizations I thought that this maybe an area that could be improved. I have the following:
var xml = new StringBuilder("");
foreach (var product in products)
{
xml.Append(product.AsXML()); // gives an xml string.
}
return String.Format("<products>{0}</products>", xml);
The xml string could be very large as the number of products in a database increase, I am wondering if there is a better way to do this.
JD