Generate an XSD (XML Schema) file from Class

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.