xmlconf
Unit XMLConf provides the XMLConfig component. It uses a TXMLDocument object to do the work of reading and writing the XMLfile, but descends directly from TComponent.
Disclaimer
This documentation is not authoritative, it is based on the usual process of (1) examining the source code (2) experimentation (3) pondering "I wonder if that is what the author had in mind ?"
Published Properties
property Filename: String
The file name of the xml file. Setting the filename to a different name:
- Flushes the current xml file.
- Frees the xmldocument object
- If Filename exists and StartEmpty is false:
- A new xmldocument is created by reading the file, which must have the same root element as RootName otherwise an exception is raised.
- Otherwise, a new xmldocument object is created with root element RootName
I have not checked this by experiment, but it appears that an empty xmldocument is created (in memory) when the component is created, and this can be modified. However, it cannot be saved until it has a file name - there is no default file name - hence all modifications will inevitably be lost when the file name is set.
property StartEmpty: Boolean
Controls whether an existing xmlfile is read from Filename.
- Default is false - an existing file is read.
property RootName: DOMString
The name of the root element in the file. Must match the value in the file when an existing file is read.
- Default is 'CONFIG'. It is simplest to leave this alone unless you have a good reason to change it.
public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Clear; procedure Flush; // Writes the XML file procedure OpenKey(const aPath: WideString); procedure CloseKey; procedure ResetKey;
function GetValue(const APath: WideString; const ADefault: WideString): WideString; overload; function GetValue(const APath: WideString; ADefault: Integer): Integer; overload; function GetValue(const APath: WideString; ADefault: Boolean): Boolean; overload; procedure SetValue(const APath: WideString; const AValue: WideString); overload; procedure SetValue(const APath: WideString; AValue: Integer); overload; procedure SetValue(const APath: WideString; AValue: Boolean); overload;
procedure SetDeleteValue(const APath: WideString; const AValue, DefValue: WideString); overload; procedure SetDeleteValue(const APath: WideString; AValue, DefValue: Integer); overload; procedure SetDeleteValue(const APath: WideString; AValue, DefValue: Boolean); overload;
procedure DeletePath(const APath: WideString); procedure DeleteValue(const APath: WideString); property Modified: Boolean read FModified; published end;
Back to fcl-xml