Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The easy method to save application settings with OmniXML is to use the <strong>OmniXMLPersistent</strong> unit.</p> <p>As explained in <a href="http://www.omnixml.com/samples.html" rel="noreferrer">OmniXML Sample Page</a> you simply define an object with published properties and with the <strong>TOmniXMLWriter</strong> class you serialize the object to a file or a string (loading with the <strong>TOmniXMLReader</strong> class)</p> <p>The serialization supports objects nested, so you could have complex structures, for example your xml could be represented by this objects:</p> <pre><code>type TAppProfiles = class(TCollection) ... end; TAppProfile = class(TCollectionItem) ... end; TAppSettings = class(TPersistent) private FCheckForUpdates: Integer; FCheckForUpdatesInterval: Integer; FShowSplashScreen: Boolean; published property CheckForUpdates: Integer read FCheckForUpdates write FCheckForUpdates; property CheckForUpdatesInterval: Integer read FCheckForUpdatesInterval write FCheckForUpdatesInterval; property ShowSplashScreen: Boolean read FShowSplashScreen write FShowSplashScreen; end; TAppConfiguration = class(TPersistent) private FProfiles: TAppProfiles; FSettings: TAppSettings; published property Profiles: TAppProfiles read FProfiles write FProfiles; property Settings: TAppSettings read FSettings write FSettings; end; //Declare an instance of your configuration object var AppConf: TAppConfiguration; //Create it AppConf := TAppConfiguration.Create; //Serialize the object! TOmniXMLWriter.SaveToFile(AppConf, 'appname.xml', pfNodes, ofIndent); //And, of course, at the program start read the file into the object TOmniXMLReader.LoadFromFile(AppConf, 'appname.xml'); </code></pre> <p>That's all.. without writing a single line of xml yourself...</p> <p>If you still prefer the "manual" way, take a look at the OmniXMLUtils units or the <a href="http://17slon.com/blogs/gabr/labels/XML.html" rel="noreferrer">Fluent interface to OmniXML</a> (written by Primoz Gabrijelcic, the OmniXML author)</p> <p>Ah.. public thanks to Primoz for this excellent delphi library!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload