Thursday, 18 February 2016

Create .Net clases from XML

We can use XML Schema Definition Tool (XSD.exe) to generate .net classes from XML. For this first we need to generate .XSD file from XML and then pass the generated .XSD file again to generate code (C# is default). Run below commands on Visual Studio command prompt. Create Schema from XML file. Below command will generate Sample.xsd file.
xsd "d:\...\Sample.xml"
Pass XML schema to XSD tool to generate code. It will generate Sample.cs file.
xsd "d:\...\Sample.xsd" /classes /language:cs
You can explore it in more details on MSDN site on following location - https://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.110).aspx  

No comments:

Post a Comment