TXMLConfig lazarus / 21-General ---------------------------------------------------------------------- dietmar · 2021-07-29 19:59 Hi, I am just playing around with TXMLConfig (from 'System' tab in Lazarus and I am reading the page https://wiki.freepascal.org/xmlconf I don't understand why the line SetValue ('L9', '99') is added to the ROOT node. Can anyone explain this to me? Thx Dietmar PS: Sorry for posting some articles in the wrong place. I will try to do better... ---------------------------------------------------------------------- marcov · 2021-07-29 20:40 Afaik the first argument is like a path. So L9 is the first level below the root. So e.g. setvalue('global/L9',99); will set a L9 value within a global tag in the root etc. ---------------------------------------------------------------------- dietmar · 2021-07-29 21:06 But it's not setvalue('global/L9',99) but just setvalue('L9', '99') ; ?!? Dietmar ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-07-29 21:16 Hey Dietmar, Quote from: dietmar on July 29, 2021, 09:59:31 pmI don't understand why the line SetValue ('L9', '99') is added to the ROOT node. Can anyone explain this to me? Could you, please, tell us what is your expectation on the result of the instruction SetValue ('L9', '99')? I ask this because in the lack of any other context, when you try and add a node to an empty XML file and you don't provide a path, it will try and add it to the ROOT node. You have to remember that you define the ROOT node and then you add all other information under that ROOT node, because there can only be ONE ROOT node. The only other way I can guess, and this IS a guess, is that you want to issue the instruction SetValue ('L9', '99') and that is made into another ROOT node? Cuz, if that's the case, let me recall what I just said above: There can only be ONE ROOT node, right? Cheers, Gus ---------------------------------------------------------------------- wp · 2021-07-29 21:22 If you look at the example in section "https://wiki.freepascal.org/xmlconf#Working_with_keys_and_paths" you see that the string of keys Code: [Select] /key1/key2/key3/key4/value="some_value"translates to the nodes Code: [Select] This means that the last key is the "value" attribute. In SetValue('L9', '99') the last key is "L9" - this is the value part. And since there are no other keys it must be the value of the root node. I agree that this is a bit strange. It would have been clearer if the SetValue syntax would have been SetValue(keys, valueName,  value) - in this case your call would have been SetValue('', 'L9', '99'). But since it has been established this way it cannot be changed any more without introducing a lot of trouble. ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-07-29 21:28 Hey Dietmar, Please completely ignore my answer!! I made a very bad mistake I'm REALLY glad WP understood it better than me and was able to explain it!! Sorry Dietmar!! And thanks so much WP!! Cheers, Gus ---------------------------------------------------------------------- dietmar · 2021-07-30 07:56 Hi all, thank you for your answers. I think I got it know. Obviously, I was confused by this ROOT attribute. Dietmar ---------------------------------------------------------------------- dietmar · 2021-08-01 20:04 Hi again, I want a XML structure like this:  
         
This is valid XML, or not? Instead, all my tries produce:  
   
 
Please help. --Dietmar ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-01 20:16 Hey Dietmar, Quote from: dietmar on August 01, 2021, 10:04:12 pmI want a XML structure like this: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  
         
This is valid XML, or not? This is NOT valid XML. Only attributes can have values not tags. In your example above, you have 2 tags(Language and Config) that you appended an equals sign after them and then a value. A tag is not supposed to have an equals sign after it, only an attribute is allowed to have an equals sign after it. I'm not sure what you're aiming at, but the XML you present after this one is valid and will hold your values. Are you trying to obtain something like this?: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  
    1    2 
If so, and from my own experience with XMLConfig, you can't obtain such result with the path thingamaboob. If I'm not mistaken you would have to deal with the DOM object and create your own Entity objects and add them in the correct position in the hierarchy. Hope this helps!! Cheers, Gus ---------------------------------------------------------------------- dietmar · 2021-08-01 21:12 Thanks for claryfing! My fear is that
would break up any string or other limits if there are many values added to them... But I will try. Fun fact: I had to google "thingamabook" and got very "interesting" page results... I think "thinamabob" was, what you meant --Dietmar ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-01 22:36 Hey Dietmar, Quote from: dietmar on August 01, 2021, 11:12:02 pmThanks for claryfing! No problem, you're quite welcome!! Quote from: dietmar on August 01, 2021, 11:12:02 pmMy fear is that
would break up any string or other limits if there are many values added to them... On a 64b CPU a string, if I'm not mistaken, has a limit above 4GB of addressed memory, way above. I would have to go and find the real limit cuz the 4GB limit was for CPUs of 32b. Or something along those lines. My memory is really crap. So, you have AT LEAST 4GB you can put on a string. Is that high enough? Some less new computers still have only 2GB of RAM, so I guess that even the 32b limit would be too high right? Ok, I went and had a look on Google to find out what's the maximum addressable amount of mem on a 64b computer: 16 EXAbytes. So, I guess that you're only limits now are the amount of RAM on the PC and/or the amount of space on the HDD, LOL!! Quote from: dietmar on August 01, 2021, 11:12:02 pmFun fact: I had to google "thingamabook" and got very "interesting" page results... I think "thinamabob" was, what you meant You are correct, the most used term is thingamabob. But I'm a very dirty old geeser and I have a very filthy sense of humour so I tend to use thingama-BOOB It's a term rather common in English speaking countries like the UK and the US and is a rather technical term to describe something you don't know the technical term of, or even the non technical term of, LOL!!!! Cheers, Gus ---------------------------------------------------------------------- dbannon · 2021-08-02 05:51 dietmar, here is a really nasty secret.  My application reads and writes XML data files. But I found writing my content as xml just too hard so I write a TEXT file with the appropriate xml tags embedded.   I use the xml unit to read that data. Code is far easier to write and infinitely easier to maintain. Davo ---------------------------------------------------------------------- dietmar · 2021-08-02 11:13 Nice ideas... will try that, thanks a lot! --Dietmar