XML Parsing

kee nethery kee at kagi.com
Tue Apr 27 22:38:24 EDT 2004


On Apr 27, 2004, at 6:38 PM, tuviah snyder wrote:

> There are samples. Check out the sample folder and open the xmltree 
> sample.

Tuviah,

Thanks but the xmltree sample is way too complex and has lots of extra 
stuff that just confuses the situation. As an example that shows the 
power of the XML routines, yes it is very cool. As a way to learn what 
each function does, it is too complex. I want to see inputs and outputs 
in the documentation. I'm working my way through lots of experiments to 
try to figure out what the functions actually do given various input 
values. I think in a day or two I'll have figured out what I need to 
get the task done but it would be helpful if the docs were a bit more 
informative. So think of this rant as a feature request.

What I want is additional text added to the online docs that shows an 
input tree for each function, and what the result is when the example 
function is called.

Kind of like if you have docs that say

add varA to varB
add 2 to theVariable
adds the variable varA to another variable varB

-- the above is the level of detail in the docs for the XML functions.
-- below is the additional level of detail I'd like to see

For example for start values:
varA = 12
varB = 6

add varA to varB

the result values are:
varA = 12
varB = 18

That kind of simple, put this in, do this, get this out kind of 
examples in the documentation that demonstrate all the various things 
you can do with a function.

On another rant entirely, something that I have not found in the online 
docs that is extremely powerful.

In various xml calls you have the following parameter definition.

"The startNode is the path to the node where you want to start."

Not exactly filled with details. None of the examples in the docs for 
the various functions show that the path can have item numbers in it. 
For example, given the following tree:

<start>
   <whatever>
     <thingie>A</thingie>
     <thingie>B</thingie>
     <thingie>C</thingie>
   </whatever>
   <whatever>
     <thingie>D</thingie>
     <thingie>E</thingie>
   </whatever>
</start>

If you want to get the value of the thingie that is currently shown as 
"E", you could set the path to:

start/whatever[2]/thingie[2]

and that uniquely identifies the path to thingie "E"

All the function docs that I have seen show example paths without the 
item counts so you are left with the impression that you have to crawl 
from whatever[1] to whatever[2] using a nextSibling function or 
something like that and then once you are at whatever[2] crawl from 
thingie[1] to thingie[2] and then ask for the value.

This one modification to how the startNode gets constructed means that 
I don't have to create a function that duplicates this kind of 
functionality using a combination of the various functions that I can 
figure out and a bunch of repeat loops.

Actually. the question I am currently battling right now is how to 
figure out that there is a "Result_1" that I should go look at in the 
following data.

<start>
   <Result_0>
     <thingie>A</thingie>
     <thingie>B</thingie>
     <thingie>C</thingie>
   </Result_0>
   <Result_1>
     <thingie>D</thingie>
     <thingie>E</thingie>
   </Result_1>
</start>

Number of children of start returns 1 and the next sibling returns 
empty. An XML tree going one level doesn't display Result_1. I'm sure 
I'll figure out how to have the functions recognize that there is a 
Result_1 but for now that is a mystery, none of my experiments have 
succeeded.

Enough rants for now. I look forward to the tutorial that Sarah is 
developing. Tiny steps is exactly what I am having to do to figure out 
what the docs are not showing.

Kee Nethery



More information about the use-livecode mailing list