A .NET/C# system receives XML messages for processing and further transmission.

Since working directly on XML documents would be very inconvenient, it is necessary to deserialize the message to a C# object and then serialize just before delivery.

Up until now this has been done with Microsoft's XSD tool (xsd.exe) and it gets the job done, but poorly. The tool is old and buggy and generates outrageous class names and code representations of the various XML schema constructs.

Are there better ways to accomplish this in .NET, or should I go a whole other way about it?

  • 2
    Are you wanting to generate a class based on the XML dynamically or do you know what fields are coming in from the XML? – Chad La Guardia Mar 20 '11 at 4:03
  • Nothing dynamic. The XML schemas are static so the classes are only generated once. – lox Mar 23 '11 at 9:00

Unless there is an insane amount of properties, or the classes are changing on the fly, I just hand-write a POCO to handle deserialization. It is a bit of up-front investment, but if these objects are being used I like to have my naming conventions, etc., in place.

| improve this answer | |
  • +1 same here. I rarely generate them unless it's a ridiculously huge doc – CaffGeek Mar 25 '11 at 16:38

If you're using Visual Studio (I'm guessing this is likely), then check out xsd2code.

I haven't used it in a while though so my memory might be a bit fuzzy, but it may just be a VS plugin wrapper around XSD.exe. Give it a shot though.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.