[Lazarus] Why was XML format chosen for storing settings in Lazarus IDE?

Marco van de Voort marcov at stack.nl
Fri Jun 18 15:14:58 CEST 2010


On Fri, Jun 18, 2010 at 02:15:30PM +0200, Graeme Geldenhuys wrote:
> On 18/06/2010, Marco van de Voort <marcov at stack.nl> wrote:
> >
> > The simple reason is that .ini is one level only, and XML has an infinite
> > nesting depth.
> 
> Could you give a small code example of how you read/write values in a
> nested hierarchy, or do you use some custom written component
> (something like TRegFile, TINIFile)?

I use laz_xml, an own modified version. 

The main reason for the modification has nothing to do with the config use.
(but with the ability to read malformed XMLs of a certain vendor, no not
Microsoft)
 
My own program has a modular shaped as a tree. It can stream its state to
a file.

> I personally don't like referencing a value via something like...
> 
>   GetXMLNode('\CompilerOptions\SomeTab\SomeValue').Text

It depends on the purpose. In my case this would be

procedure tsometab.loadfromxml(xml:TXMLConfig;key:string);

begin
 somevalue:=xmlgetvalue(key+'/SomeValue','SomevalueDefault');
end;

with sometab being loaded from the compileroptions module, which is in turn
called by Main.
 
> If so, INI files could be used in exactly the same way (as my previous
> post about Windows regedit showed).

I see no point in inventing own formats for something as benign as this.

Hierarchical structures are always harder to edit with a linear editor
like a texteditor. If it bothers you, make a general hierarchical editor
based on a treeview. (and probably there are already many)




More information about the Lazarus mailing list