Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a class consisting of attributes such as ID , Name , Address . I have a list of classes , I want to save the xml file , how can I do ? thsnks so much
Posted

1 solution

You can store (persist, store/load) not just a class, but an arbitrary object graph of any structure (not necessarily hierarchical) using Data Contract. This is most non-intrusive and easy-to-use approach; you only add attributes to types and members, so not modifications of types themselves are required.

See: http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^],
deseralize a json string array[^].

—SA
 
Share this answer
 
Comments
thatraja 28-Dec-11 5:05am    
5!
Sergey Alexandrovich Kryukov 28-Dec-11 17:44pm    
Thank you, Raja.
--SA
Espen Harlinn 28-Dec-11 12:29pm    
Agree
Sergey Alexandrovich Kryukov 28-Dec-11 17:45pm    
Thank you, Espen.
--SA
Monjurul Habib 28-Dec-11 14:57pm    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900