开发者

Generating C# class file from XML Schema

开发者 https://www.devze.com 2022-12-11 01:15 出处:网络
I wa开发者_如何学编程nt to parse a complex XML schema file and export to a C# file. Do I need take use System.XML.Schema namespace?You can use XSD.EXE, and the command will be something like this:

I wa开发者_如何学编程nt to parse a complex XML schema file and export to a C# file.

Do I need take use System.XML.Schema namespace?


You can use XSD.EXE, and the command will be something like this:

XSD.EXE your.xsd /c

The generated source has a couple of quirks:

  • It generates [SerializableAttribute], [XmlTypeAttribute], [XmlRootAttribute], etc., rather than [DataContract] and [DataMember], which may (not) be a problem for you.
  • It defines child/detail structures using arrays within, rather than generic List<T> structures.

I usually have to tweak it fairly heavily (with a few search & replace operations), plus manually handling the lists. Regardless, it provides a good starting point.


You need to use the XSD tool. It does have limitations but it is free and likely already on your system.

If you need bigger and costlier guns I'd suggest Liquid Xml Studio or Altova.

0

精彩评论

暂无评论...
验证码 换一张
取 消