[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:
>>
>>> Hello,
>>>
>>> I am trying to use XmlConfig to store simple configuration data, but I
>>> can't
>>> 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
>>> it
>>> 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' ;
> begin
>   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 ;
>   XmlConfig1.Flush
> end;
>
> (No, it does not make any sense, just me trying to figure out how it
> works.)
>
> And here is the result:
>
> <?xml version="1.0" encoding="utf-8"?>
> <CONFIG L8="dd">
>   <CONFIG L5="xx"/>
>   <L1 L2="cc" L3="bb"/>
> </CONFIG>
>
> 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
(davitof)

Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20131127/10bf2372/attachment-0003.html>


More information about the Lazarus mailing list