Creating XML schema and auto-generate the serializable class out of it using Visual Studio 2010

后端 未结 1 1628
慢半拍i
慢半拍i 2020-12-30 12:27

I am trying to create an XML schema to be serialized/deserilized using visual studio 2010, but it looks really complicated having an xml file and another xml schema file, I

相关标签:
1条回答
  • 2020-12-30 13:18

    Let me try to answer this:

    1. open your VS project.
    2. open the XML on your project.
    3. On VS, go to the menu tab and click on create schema
    4. save the schema file and added to your project.

    Then you can create your own class for the serialize/deserialize process or use xsd.exe

    I used the last one. In my case I can found the tool in the \Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\xsd.exe.

    Then you can open CMD or the Visual Studio command window and write something like: xsd.exe [THE XSD FILE] /c /l:c# /o:[DIRECTORY WHERE YOU WANT TO SAVE THE .CS]

    I hope this works for you or answer your question. Pretty much I used the same approach with VS 2008 and 2010.

    Here are related topics just in case:

    XSD tool: https://docs.microsoft.com/en-us/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe

    XML Serialization and Schema without xsd.exe

    Generate classes from XSD

    if you don't have the Microsoft SDK you can get it from: https://docs.microsoft.com/en-us/dotnet/core/sdk

    0 讨论(0)
提交回复
热议问题