In a recent open API project, results must be provided to a third party in XML format. Because it is an open interface and XML Schema (XSD) needs to be provided at the same time, it takes some time to learn XSD and then write it manually. Later, we found that the. NET Framework provided the xsd.exe tool to automatically generate the XSD file from the class. For friends who are not familiar with XSD, a shortcut is provided to write XSD: Write the class first, compile it into dll/exe, and then generate the corresponding XSD file through xsd.exe.
The following describes how to use xsd.exe:
(1) Open the. NET Framework SDK command line (my path is: D: \ "Program Files" \ Microsoft Visual Studio 8 "SDK" \ V2.0)
(2) Enter "XSD-h" to view the help information, from class to XSD: xsd.exe <Assembly>. DLL |. EXE [/outputdir:] [/type: [...]
(3) run the command "xsd.exe sample. dll/type: myclass" according to the help"
Note: The class requires some conditions, such as serialization and a default constructor. Otherwise, an error is returned when running the command.