3

I want to parse a complex XML schema file and export to a C# file.

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

2
  • 2
    Given that you are parsing XML it would make sense to use that part of the framework but it's by no means mandatory. Go give it a try and if you get stuck then come back, show what you are doing, describe how it's not working and I'm sure you'll get some help. Commented Nov 12, 2009 at 12:59
  • Hi Sir Lazarus, Good day. I will collect my detail questions/requirements at the comming study days. Thank you. Nano Commented Nov 16, 2009 at 3:57

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Sir Mike, Good day. I followed your command from .net 2.0 SDK command line, and i generated my C# file from my XSD file successfully. I am research more about my new C# file. thank you. Nano
4

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.

1 Comment

Thank you sir Typtseven too. I think i could study XSD tool and try to work out my SR. Appreciated for your resource. BR! Nano

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.