C#保存xml数据的最佳方法 [英] C# Best way to hold xml data
本文介绍了C#保存xml数据的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
保存这些数据的最佳解决方案是什么?
也许使用SQLite保留一些历史记录?
解决方案
您可以将其流式传输到文件中:
///保存:System.Xml.XmlDocument doc =新的System.Xml.XmlDocument();System.IO.File.WriteAllText(filename,doc.Value);///将其加载回:System.Xml.XmlDocument xdoc =新的System.Xml.XmlDocument();xdoc.LoadXml(System.IO.File.ReadAllText(filename));
Im requesting data from web service and receive a xml file.Not do flood the service good idea would be to cache/store the xml so when the application is started again it would use that cached xml. The data in received xml will change in every 24 hours so afther that time is passed from old request application must create new one anyway.
What would be the best solution to keep that data?
EDIT: Maybe use SQLite to keep some history?
解决方案
You can just stream it to a file:
/// saving it :
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.IO.File.WriteAllText(filename, doc.Value);
/// loading it back in :
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.LoadXml(System.IO.File.ReadAllText(filename));
这篇关于C#保存xml数据的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文