How to create an xml file in the form of c# list.The list will be populated with the data from database.
Can any1 help me on this
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Sep 15, 2011, 10:46 PM
What is the purpsoe of the list?
I ask these things just to help us understand what you need. We are eager to help you but we need to understand.
VulpesPosted Sep 15, 2011, 12:11 PM
and the code to serialize the list to disk will be the same as before.
Incidentally, you can write the datatable directly to an XML file, without going through a list at all, using the DataTable.WriteXml(fileName) method. It won't be quite the same as what we've done here but it should be good enough :)
SweetyPosted Sep 15, 2011, 4:51 AM
VulpesPosted Sep 15, 2011, 4:35 AM
Here's a simple example:
This code should produce the following XML file: