<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2013/11/27 Mattias Gaertner <span dir="ltr"><<a href="mailto:nc-gaertnma@netcologne.de" target="_blank">nc-gaertnma@netcologne.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5">On Wed, 27 Nov 2013 16:54:45 +0100<br>
Frederic Da Vitoria <<a href="mailto:davitofrg@gmail.com">davitofrg@gmail.com</a>> wrote:<br>
<br>
> 2013/11/27 Frederic Da Vitoria <<a href="mailto:davitofrg@gmail.com">davitofrg@gmail.com</a>><br>
><br>
> > 2013/11/27 waldo kitty <<a href="mailto:wkitty42@windstream.net">wkitty42@windstream.net</a>><br>
> ><br>
> >> On 11/27/2013 6:50 AM, Frederic Da Vitoria wrote:<br>
> >><br>
> >>> Hello,<br>
> >>><br>
> >>> I am trying to use XmlConfig to store simple configuration data, but I<br>
> >>> can't<br>
> >>> make it create a sensible Xml file. This is not really important in my<br>
> >>> situation, as XmlConfig is able to correctly read back the strange data<br>
> >>> it<br>
> >>> wrote, but frustrating. I searched the web but could not find any<br>
> >>> example. So<br>
> >>> can anyone offer a working example of creating a xml file with XmlConfig?<br>
> >>><br>
> >><br>
> >> can you provide a sample of what is being created and what you are<br>
> >> expecting to actually see?<br>
> >><br>
> ><br>
> > I'm trying something like (just the minimum code, but I can give the<br>
> > complete sources if it makes things easier):<br>
> ><br>
> > procedure TForm1.Button1Click(Sender: TObject);<br>
> > const FILE_NAME = 'pXmlConfig.xml' ;<br>
> > begin<br>
> >   XmlConfig1.Filename := FILE_NAME ;<br>
> > //  XmlConfig1.OpenKey ('/CONFIG') ;<br>
> >   XmlConfig1.SetValue ('/CONFIG/L5', 'xx') ;<br>
> >   XmlConfig1.SetValue ('/L1/L2', 'aa') ;<br>
> >   XmlConfig1.SetValue ('/L1/L3', 'bb') ;<br>
> >   XmlConfig1.SetValue ('/L1/L2', 'cc') ;<br>
> >   XmlConfig1.SetValue ('/L8', 'dd') ;<br>
> > //  XmlConfig1.CloseKey ;<br>
> >   XmlConfig1.Flush<br>
> > end;<br>
> ><br>
> > (No, it does not make any sense, just me trying to figure out how it<br>
> > works.)<br>
> ><br>
> > And here is the result:<br>
> ><br>
> > <?xml version="1.0" encoding="utf-8"?><br>
> > <CONFIG L8="dd"><br>
> >   <CONFIG L5="xx"/><br>
> >   <L1 L2="cc" L3="bb"/><br>
> > </CONFIG><br>
> ><br>
> > The only thing which worked as I wanted is that SetValue ('/L1/L2', 'aa')<br>
> > is overwritten by SetValue ('/L1/L2', 'cc')<br>
<br>
</div></div>The empty root '/' at the beginning is not needed.<br>
<div class="im"><br>
<br>
> > - How do I create third level keys? (or is XmlConfig able to do more than<br>
> > 2 levels?)<br>
<br>
</div>cfg.SetValue('/L1/L2/L3','value');<br>
<div class="im"><br>
<br>
> > - Why does XmlConfig create L2, L3 and L5 as attributes ("/" usually is a<br>
> > level separator, is it not) ?<br>
<br>
</div>TXMLConfig is a simple wrapper to store name/value pairs in xml.<br>
You can access the full XML via cfg.Doc.<br>
<div class="im"><br>
<br>
> > - More generally, is XmlConfig suited to do more than a simple list<br>
<br>
</div>You can store lists, trees, graphs as name/value pairs.<br>
<div class="im"><br>
<br>
> > (which would be even less than a .ini can do)?<br>
<br>
</div>If you only use TXMLConfig and not the Doc then it can do the same as<br>
a TIniFile. Of course there are speed and size differences.<br>
<div class="im"><br>
<br>
> Now that I am thinking of it, I may be expecting too much. If XmlConfig<br>
> handles more than 2 levels, then why stop to 3? And then, how would<br>
> XmlConfig be different from a full Xml Implementation?<br>
<br>
</div>TXMlConfig uses a pretty complete XML parser/writer.<br></blockquote></div><br></div><div class="gmail_extra">Thanks to all the advice, I managed to make it work. I will add my example to the wiki in order to make this clear to other users as ignorant as I am :-)<br clear="all">

</div><div class="gmail_extra"><br>-- <br>Frederic Da Vitoria<br>(davitof)<br><br>Membre de l'April - « promouvoir et défendre le logiciel libre » - <a href="http://www.april.org" target="_blank">http://www.april.org</a><br>


</div></div>