Hello.
Good day.
I want to parse a complex XML schema file and export to a C# file.
Does i need take use System.XML.Schema namespace ?
I don't know how to start my job.
Thanks in advance.
BR! Nano
Hello.
Good day.
I want to parse a complex XML schema file and export to a C# file.
Does i need take use System.XML.Schema namespace ?
I don't know how to start my job.
Thanks in advance.
BR! Nano
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.
XSD Object Gen is better than the XSD tool in my experience.
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:
[SerializableAttribute]
, [XmlTypeAttribute]
, [XmlRootAttribute]
, etc., rather than [DataContract]
and [DataMember]
, which may (not) be a problem for you.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.