Delphi Classes to XML representation:

Vector picture Vector · Mar 28, 2013 · Viewed 8.5k times · Source

Using Delphi XE:

XML data binding wizard generates Delphi class based on XML/XSD - works great.

BUT I also need to go the other way: Convert Delphi classes into XML. I don't find any support for that in XE. (I know this is quite simple to accomplish with C#, .NET, but obviously, since Delphi doesn't really support Reflection it's a lot more difficult than with C#)

One option I do have it is write the class in C# with SharpDevelop and use the MS utility (which I believe is a free download) to generate XML from the C# code. I also have VS 2005 that supports this, but it's not installed and I'd prefer not get to involved with it).

Anyone have a suggestion as to how to go about getting this done: Straight from Delphi to XML/XSD? An open source tool would be nice, or some good units that will do this.

Answer

mjn picture mjn · Mar 28, 2013

The NativeXml and OmniXML open source libraries can convert Delphi objects to XML (not XSD). They support object serialization and deserialization even with Delphi versions before 2010.

So it would be possible to use them in a first step to create a XML file, which then can be passed to the Data Binding Wizard for Delphi class code generation.