如何保存XML文件中的数据以及如何从ASP.net中的XML文件读取数据 [英] How to preserve data in XML file and read data from XML file in ASP .net
本文介绍了如何保存XML文件中的数据以及如何从ASP.net中的XML文件读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在XML文件中保留一些数据,并且在页面加载时需要读取xml
我该怎么做?
i want to preserve some data in XML file and on page load need to read that xml
how can i do it?
推荐答案
.NET中有几种不同的XML持久性方法.您不必手动"使用XML.我建议使用Data Contract
.它有助于存储和恢复任何对象图,而不会影响数据类型的声明.您只需将[DataContract]
和[DataMember]
之类的属性添加到声明中并使用DataContractSerializer
.
请参阅 http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].
另请参阅我过去的答案:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [
There are several different approached to XML persistence in .NET. You don''t have to work with XML "manually". I would advice usingData Contract
. It helps to store and restore any object graph without any intrusion into declaration of data types. You only add attributes like[DataContract]
and[DataMember]
to declarations and use theDataContractSerializer
.
See http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].
See also my past answers:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^].
—SA
这篇关于如何保存XML文件中的数据以及如何从ASP.net中的XML文件读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文