首页 > Web开发 > 详细

netcore XmlDocument 使用Load和Save方法

时间:2019-11-21 21:35:00      阅读:232      评论:0      收藏:0      [点我收藏+]
                string path ="C://xxx/file"
                XmlDocument xmlDoc = new XmlDocument();
 
#if NET462
                xmlDoc.Load(path);
#else
                string content = File.ReadAllText(path);
                xmlDoc.LoadXml(content.Trim());
#endif
 
……
……
 
#if NET462
                xmlDoc.Save(path);
#else
                FileStream fs = new FileStream(path, FileMode.Create);
                XmlWriterSettings settings = new XmlWriterSettings() { Indent = true };
                XmlWriter writer = XmlWriter.Create(fs, settings);
                xmlDoc.Save(writer);
#endif

 

netcore XmlDocument 使用Load和Save方法

原文:https://www.cnblogs.com/cnhk19/p/11908426.html

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