C# How to create XSD & .Net Class file using Command prompt for C# XmlSerializer
There are various ways to create & read xml files. Usually we create a class & read it using xdocument or xmldocument. For that we need to create declare variables for the class & use GET SET method. Another alternative is to create XSD file from XML using XSD.EXE tool. From the XSD, we can create .Net class file which can read your XML data using class XmlSerializer.
This tool will create XSD & Class file instantaneously, without a single line of code . Lets see how can you do it.
This tool will create XSD & Class file instantaneously, without a single line of code . Lets see how can you do it.
- Suppose you have file in folder. C:\TEST & you have a file LinkData.xml in it.
- Open Visual Studio Command prompt from the menu.
- Type C:\>cd C:\TEST & press ENTER to set the current directory.
- Type C:\TEST>xsd.exe LinkData.xml
- This will create XSD file of your XML file in the same directory.
Create the .net Class file for reading xml data
- Now type xsd.exe /classes /namespace:myClass LinkData.xsd
- Replace myClass by the namespace of project in which you will be adding the class file.
- It will create a class file with myClass namespace in it.
C# How to create XSD & .Net Class file using Command prompt for C# XmlSerializer
There are various ways to create & read xml files. Usually we create a class & read it using xdocument or xmldocument. For that we need to create declare variables for the class & use GET SET method. Another alternative is to create XSD file from XML using XSD.EXE tool. From the XSD, we can create .Net class file which can read your XML data using class XmlSerializer.
This tool will create XSD & Class file instantaneously, without a single line of code . Lets see how can you do it.
This tool will create XSD & Class file instantaneously, without a single line of code . Lets see how can you do it.
- Suppose you have file in folder. C:\TEST & you have a file LinkData.xml in it.
- Open Visual Studio Command prompt from the menu.
- Type C:\>cd C:\TEST & press ENTER to set the current directory.
- Type C:\TEST>xsd.exe LinkData.xml
- This will create XSD file of your XML file in the same directory.
Create the .net Class file for reading xml data
- Now type xsd.exe /classes /namespace:myClass LinkData.xsd
- Replace myClass by the namespace of project in which you will be adding the class file.
- It will create a class file with myClass namespace in it.