Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Classes to XML representation:

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.

like image 854
Vector Avatar asked Mar 28 '13 17:03

Vector


2 Answers

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.

like image 189
mjn Avatar answered Nov 01 '22 22:11

mjn


Robert Love wrote an article in late 2009 covering that topic: Xml Serialization - Basic Usage. It uses the "new" RTTI available as of Delphi 2010.

like image 23
Rob Kennedy Avatar answered Nov 01 '22 22:11

Rob Kennedy