首页 > Windows开发 > 详细

c# xml操作

时间:2015-10-27 19:22:30      阅读:186      评论:0      收藏:0      [点我收藏+]

xmldocument

 1 XmlDocument result = new XmlDocument();
 2 
 3             //root
 4             XmlElement root = result.CreateElement("root");
 5             result.AppendChild(root);
 6 
 7 
 8             StampService mrs = new StampService();
 9             IQueryable<BI_StampInfo> carres = mrs.GetAllBases();
10             if (carres != null)
11             {
12                 List<BI_StampInfo> carlist = carres.ToList();
13                 foreach (BI_StampInfo item in carlist)
14                 {
15                     //info
16                     XmlElement info = result.CreateElement("info");
17                     root.AppendChild(info);
18 
19                     //elements
20                     XmlElement Type1 = result.CreateElement("类别");
21                     Type1.InnerText = item.Type;
22                     Type1.SetAttribute("newAttribute", "test");
23                     info.AppendChild(Type1);
24 
25                     
26                 }
27             }
28 
29             return result;

 

c# xml操作

原文:http://www.cnblogs.com/King-JJ/p/4914947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!