[Lazarus] How is XMLConfig supposed to work?
Frederic Da Vitoria
davitofrg at gmail.com
Wed Nov 27 16:54:45 CET 2013
2013/11/27 Frederic Da Vitoria <davitofrg at gmail.com>
> 2013/11/27 waldo kitty <wkitty42 at windstream.net>
>> On 11/27/2013 6:50 AM, Frederic Da Vitoria wrote:
>>> I am trying to use XmlConfig to store simple configuration data, but I
>>> make it create a sensible Xml file. This is not really important in my
>>> situation, as XmlConfig is able to correctly read back the strange data
>>> wrote, but frustrating. I searched the web but could not find any
>>> example. So
>>> can anyone offer a working example of creating a xml file with XmlConfig?
>> can you provide a sample of what is being created and what you are
>> expecting to actually see?
> I'm trying something like (just the minimum code, but I can give the
> complete sources if it makes things easier):
> procedure TForm1.Button1Click(Sender: TObject);
> const FILE_NAME = 'pXmlConfig.xml' ;
> XmlConfig1.Filename := FILE_NAME ;
> // XmlConfig1.OpenKey ('/CONFIG') ;
> XmlConfig1.SetValue ('/CONFIG/L5', 'xx') ;
> XmlConfig1.SetValue ('/L1/L2', 'aa') ;
> XmlConfig1.SetValue ('/L1/L3', 'bb') ;
> XmlConfig1.SetValue ('/L1/L2', 'cc') ;
> XmlConfig1.SetValue ('/L8', 'dd') ;
> // XmlConfig1.CloseKey ;
> (No, it does not make any sense, just me trying to figure out how it
> And here is the result:
> <?xml version="1.0" encoding="utf-8"?>
> <CONFIG L8="dd">
> <CONFIG L5="xx"/>
> <L1 L2="cc" L3="bb"/>
> The only thing which worked as I wanted is that SetValue ('/L1/L2', 'aa')
> is overwritten by SetValue ('/L1/L2', 'cc')
> - How do I create third level keys? (or is XmlConfig able to do more than
> 2 levels?)
> - Why does XmlConfig create L2, L3 and L5 as attributes ("/" usually is a
> level separator, is it not) ?
> - More generally, is XmlConfig suited to do more than a simple list (which
> would be even less than a .ini can do)?
Now that I am thinking of it, I may be expecting too much. If XmlConfig
handles more than 2 levels, then why stop to 3? And then, how would
XmlConfig be different from a full Xml Implementation?
Frederic Da Vitoria
Membre de l'April - « promouvoir et défendre le logiciel libre » -
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus