C# 构建XML的简单示例:

 var pars = new Dictionary<string, string>
{
{"url","https://www.baidu.com/"},
{"name","jack"},
{"sex",""},
};
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
xtw.WriteStartElement("xml");
foreach (var par in pars)
{
xtw.WriteElementString(par.Key, par.Value);
}
xtw.WriteEndElement();
Console.WriteLine(sw.ToString());
04-30 04:19