المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to convert flat files to XML using c#



C# Programming
03-30-2009, 05:00 AM
Hello everyone,

I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method. I am given with the various flat files and corresponding mapping files. These mapping files itself are in XML (.ltm extension). Now I have to generate XML files from the flat files that adhere to the schema of these mapping files. And for this I have to use XML serialization and deserialization process written in c# code.

Why XML serialization/deserialization?
Because I have generated xsd of the given xml mapping files and imported that file into my solution as xsd.cs so that I can have various nodes of this mapping file available to me as a classes. I mean, I can directly write classes belonging to various elements in this mapping file. As a result I do not have to parse these mapping files using Read and Write properties.

I am asked to create the instances of these classes and use the serialize/deserialize methods to get the work done. Now my problem is that I do not know how to exactly create the classes in this situation and go about serialization and deserialization. So can any one help me out in this situation by providing some sample codes/snippets related to my work. It would be great if someone can actually provide me with steps/algorithm to go about this project. Let me specify one more thing, all the mapping files corresponding to different flat files have the same structure, only the text values corresponding to various Elements are different.

Thank you very much.