生成C#从XML类XML

2023-09-02 10:15:59 作者:萝莉味儿软妹酥

我可以从XML文件生成一个C#类?

Can I generate a C# class from an XML file?

推荐答案

是,通过 XSD.EXE

D:temp>xsd test.xml
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:temptest.xsd'.

D:temp>xsd test.xsd /classes
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:temptest.cs'.