Hi,
The StringBuilder is simple and best approach to your requirements.
I guess the desired output is like this:
<key>value</key>
If so, make sure the key is a valid XML identifier.
The safer way is <item key="key">value</item>.
Sample code:
const string pattern = "<item key=\"{0}\">{1}</item>";
StringBuilder buffer = new StringBuilder("<table>");
foreach (DictionaryEntry entry in theHashTable)
{
buffer.AppendFormat(pattern, entry.Key, entry.Value);
}
buffer.Append("</table>");
return buffer.ToString();
Hope it helps,
Thi
http://thith.blogspot.com
Joe wrote:
Thanks for the response. The desired output is just the key as the element
with the value. Is StringBuilder the best approach?