What's a good way to serialize Delphi object tree to XML–using RTTI and not custom code?-Collection of common programming errors
JVCL is one choice, but if you prefer a small, self-contained library, there’s OmniXML (Mozilla Public License 1.1, http://www.omnixml.com/ ). I’ve used it successfully in several projects, and I find it the simplest XML library to use in Delphi. OmniXML comes with ‘OmniXMLPersistent’ unit, which does what you need via RTTI, just like the JVCL solution does.
// saving:
pers : TPersistent;
// SaveToFile is a class method, so no need to instantiate the object:
TOmniXMLWriter.SaveToFile( pers, 'd:\path\file.xml', pfAttributes, ofIndent );
pfAttributes means properties will be stored as attributes of XML elements; ofIndent will produce a nicely indented code for readability.
// loading:
TOmniXMLWriter.LoadFromFile( pers, 'd:\path\file.xml' );