Tree Arrays: putting XML in nested arrays

Trevor DeVore lists at mangomultimedia.com
Thu Jan 1 09:45:58 EST 2009


On Dec 31, 2008, at 11:59 AM, David Bovill wrote:

>  One question about the data structure:
>
> [root]
>>   [@attributes]
>>       [attr1]
>>   [node]
>>       [node] = value
>
> This would mean that to extract the plain tree structure you would  
> have to:
>
> filter keys(someArray) without "@*"
>
> Isn't this unnecessarily slow?
> What do you think about:
>
>   - put treeArray ["_tree"]["root"]["node"][1] into nodeContents
>   - put treeArray ["_attribute"]["root"]["node"][1]["style"] into  
> nodeStyle
>   - put keys(treeArray ["_tree"]["root"]) into level1
>
> Out of interest what do you use them for?

I've never timed the overhead of filter but in my case I don't notice  
a speed hit and the structure isn't unnecessary. I use these  
conversion routines to facilitate interfacing with web services. As  
soon as I receive a response from the server I convert it to a  
Revolution array. If I need to send a request then I create an array,  
convert to XML and send it. Often I need to be able to extract an  
entire node and send it to a function for further processing. If the  
attributes were stored in a different branch in the array then it  
would complicate the code for doing this.

In general I've found I can code much more quickly and end up with  
more readable code when working with the new MD arrays as opposed to  
the revXML calls.

Regards,

-- 
Trevor DeVore
Blue Mango Learning Systems
www.bluemangolearning.com    -    www.screensteps.com



More information about the Use-livecode mailing list