Navigating XML in LiveCode

Graham Samuel livfoss at mac.com
Wed Jan 25 13:03:45 EST 2012


Thanks again for the replies Bernard and Richard. I have learned a lot in these conversations. In my LC coding life I have not had to use an SQL database or JSON, and as I have my work cut out just getting to understand iOS development and all that it implies (including non-technical stuff like "can I send a copy of my work in progress for the iPhone to my colleague who is literally on the other side of the world, or does Apple prevent this?") I don't at this time want to learn more stuff than I have to, tho it would doubtless improve my mind to learn it all eventually.

Bernard you are right, CSV is not good for a data structure where some of the data may be either missing or duplicated. By the time one has put in enough labelling info to make that work in CSV, it's practically XML.

Richard I like the arrayEncode/deCode idea - it doesn't look like much of a learning curve.

I'll keep quiet now and go back to coding.

Graham

On Tue, 24 Jan 2012 12:13:38 +000, Bernard Devlin <bdrunrev at gmail.com> wrote:

> You could also consider using JSON instead of XML.  Particularly since
> we have 2 libraries around which convert LiveCode arrays to JSON and
> vice-versa.  JSON is known as "the fat-free xml".  I don't think
> either format is paritcularly easy to scan by the naked eye.  One
> library is by Andre, the other by Mark Smith.
> 
> Another option would be to use a sqlite database, and have your
> program export/backup the database to a series of SQL insert
> statements.  I think I'd find that easier to scan with the naked eye
> than XML.
> 
> I don't understand why a CSV (or tab-separated) text file would not
> suit your purposes, but I'll assume it because your data is more
> complex than would be suitable to that format.
> 
> Bernard
> 
On Tue, 24 Jan 2012 06:53:54 -0800, Richard Gaskin <ambassador at fourthworld.com> wrote:
> XML is the way to go for inter-app data transfer, but FWIW if your app 
> was the only one using it you can save arrays to disk using 
> arrayEncode/arrayDecode:
> 
> global gMyArray
> 
> on LoadData pFile
>    put url ("binfile:"& pFile) into tData
>    put arrayDecode(tData) into gMyArray
> end LoadData
> 
> on SaveData pFile
>    put arrayEncode(gMyArray) into tData
>    put tData into url ("binfile:" & pFile)
> end SaveData


> 
> On Mon, Jan 23, 2012 at 4:34 PM, Graham Samuel <livfoss at mac.com> wrote:
>> However the real reason that I'm trying to go down the XML route is that I need this data to persist and I don't want the overhead of storing it in a stack rather than just keeping a trivial amount of text which furthermore could be easily examined/edited by non-LC programs.
> [...]
>> I suppose more generally I'm trying to understand if XML is suitable for this kind of data structure, where there are several nodes identical or similar in structure but containing different data. It looks ideal to me, but the difficulty of finding the last item you added, and of adding attributes at creation time, is giving me doubts. But maybe I'm just confused.




More information about the use-livecode mailing list