Last post Feb 05, 2015 01:30 PM by AidyF
Feb 04, 2015 05:25 AM|Shibly|LINK
I want to create a xml file from a List<T> object. Can anyone help me please.
Thanks in advance.
Feb 04, 2015 06:11 AM|AidyF|LINK
You could create an XML structure\file programmatically using XmlWriter or XmlDocument, or you could use XML Serialisation to create the document for you from your list.
Feb 04, 2015 06:59 AM|smirnov|LINK
See examples: http://stackoverflow.com/questions/8334527/c-sharp-save-listt-to-xml-file
Feb 05, 2015 12:22 PM|Shibly|LINK
Your solution really help me a lot but now I faced another problem which is I create the List<T> using entity framework so when the xml serialization convert the list data it show that "InvalidOperationException" because it's want the class in
public but I've use entity framework for create the database object and get the database data.So I don't understand how to do that. My list look like this
List<User> usr = new List<User>();
Can you help me please.
Feb 05, 2015 01:30 PM|AidyF|LINK
If you want certain properties to be ignored by serialization you normally decorate them with an attribute like
if that is possible or not with your EF classes depends on how you are using EF really. You could always look at custom serialization but that's going to be more work
however it gives you complete control over the process.