你的位置:首页 > ASP.net教程

[ASP.net教程]C# 构建XML(简单示例)


C# 构建

 1 var pars = new Dictionary<string, string>  2       { 3         {"url","https://www.baidu.com/"}, 4         {"name","jack"}, 5         {"sex","0"}, 6       }; 7       StringWriter sw = new StringWriter(); 8       new  9       xtw.WriteStartElement("");10       foreach (var par in pars)11       {12         xtw.WriteElementString(par.Key, par.Value);13       }14       xtw.WriteEndElement();15       Console.WriteLine(sw.ToString());