How to create a C# Class from XML file (via xsd.exe)
A friend asked me a couple of times about how to I created the class I used in “twitter common friends” to handle xml as objects (includes reading & writing back). Actually the tool (xsd.exe) is pretty simple & takes no more than a couple of commands to create the class for me.
It’s just that I usually forget the keywords/parameters & their order (you can create a dataset or class that can be C# or VB, & there’s a couple of other option I never used before). I usually refer to its MSDN page when asked..
So I thought a post would be easier to remember. First you should create the xsd file out of the xml, using the VS command prompt:
xsd myFile.xml
That will create “myFile.xsd”, now to create “myFile.cs”, write the below line:
xsd myFile.xsd /c
Now you can add the cs file to your project & use it as illustrated in my previous post.
1 comment:
Thanks Rahul for you comment.. Hope to see more of your comments around the blog.. Thanks for sharing urs too.. seems interesting :)
Post a Comment