码迷,mamicode.com
首页 > Windows程序 > 详细

C# 构建XML(简单示例)

时间:2016-02-29 16:09:35      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

C# 构建XML的简单示例:

 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             XmlTextWriter xtw = new XmlTextWriter(sw);
 9             xtw.WriteStartElement("xml");
10             foreach (var par in pars)
11             {
12                 xtw.WriteElementString(par.Key, par.Value);
13             }
14             xtw.WriteEndElement();
15             Console.WriteLine(sw.ToString());

 

C# 构建XML(简单示例)

标签:

原文地址:http://www.cnblogs.com/q975261413/p/5227391.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!