Working with XML document type definitions in .net

2019-06-04 23:09发布

问题:

Is it possible to import an XML DTD into Visual Studio in order to generate a proxy class?

I have a third party .dll that I need to interface with that is designed like an XML service. The interface into the .dll is all driven by XML inputs, and returns output as XML. The nice thing about it is that all the input and output types are well defined. The bad news is that they use DTD (Document Type Definition).

I would really like not to have to build up the XML by hand, but I only know how to use XSD files .Net

回答1:

Visual Studio can handle converting your DTD to an XSD, at which point you could generate your proxy.

You should just be able to load your DTD into the XML designer, choose "Create Schema", and have Visual Studio infer the XSD from it.



回答2:

Reduce the problem to one you know how to solve. DTDs and XSDs are roughly equivalent, and converters exist to convert DTDs to XSDs. You know how to work with XSDs, so you've reduced it to a solvable problem.