也使用示例XML文件来生成带有XML文件中的值的C#代码 [英] Use sample XML file to generate c# code with values from XML file too

查看:61
本文介绍了也使用示例XML文件来生成带有XML文件中的值的C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xsd并从中生成了类.我也有一个带有值的示例XML文件.有没有一种方法可以自动生成/编写可以实例化类并分配值以再次使用值重新创建XML的c#方法?  任何

I have an xsd and generated classes from it. I also have a sample XML file with values. Is there a way I can automatically generate/write a c# method that could instantiate classes and assign the values to recreate the XML with the values again?  Any ideas would be greatly appreciated! 

推荐答案

Hi  jpro1000,

Hi jpro1000,

感谢在那里发布.

>> 有没有一种方法可以自动生成/编写可以实例化类并分配值以再次使用值重新创建XML的ac#方法?

也许您可以使用vs2015的开发命令提示符来自动生成/编写c#方法.

Maybe you could use develop command prompt for vs2015 to  automatically generate/write a c# method.

您可以单击开始菜单,然后选择vs2015的开发命令提示符.然后,我们可以通过CD解决方案找到解决方案的内容.

You could click start menu and choose develop command prompt for vs2015 .Then we could find solution content by CD solution .

如果要将XML文件转换为XSD,可以使用" xsd xx.xml   "命令.

If we want to convert XML files to XSD ,we could use "xsd xx.xml   "command.

如果我们想生成相应的类,我们可以使用此命令" xsd /c/ namespace:myCompany /语言:CS temp1.xsd "

If we want to  generate corresponding class we could use this command" xsd /c /namespace:myCompany /language:CS temp1.xsd "

这是我的屏幕截图:

这是结果:

如果您对C#语法还有其他疑问,请随时告诉我.

If you have anything else regarding C# grammar ,please free to let me know.

最诚挚的问候

凯文


这篇关于也使用示例XML文件来生成带有XML文件中的值的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆