How can I convert an XSD file to C# Class

前端 未结 2 1488
长发绾君心
长发绾君心 2020-12-24 06:30

I have a file in XSD format. How can I convert it to a C# class?

I need class reference in other web applications where I need to make post call as per below:

相关标签:
2条回答
  • 2020-12-24 07:11

    Use the XML Schema Definition Tool xsd.exe found in your framework tools to convert your schema into a serializable class or dataset.

    xsd file.xsd {/classes | /dataset} [/element:element]
             [/language:language] [/namespace:namespace]
             [/outputdir:directory] [URI:uri]
    

    And in example, whereas the C# class will be generated in the same directory as the xsd tool:

    xsd /c YourFile.xsd
    
    0 讨论(0)
  • 2020-12-24 07:23

    you can do like this...

      <xsd xmlns='http://microsoft.com/dotnet/tools/xsd/'>
    <generateClasses language='CS' namespace='Namespace.subnamespace'>
        <schema>FirstSchema.xsd</schema>
        <schema>AnotherSchema.xsd</schema>
        <schema>LastSchema.xsd</schema>
    </generateClasses>
    </xsd>
    
    0 讨论(0)
提交回复
热议问题