bratliff wrote:
> On Nov 20, 4:49 pm, Garthan <[EMAIL PROTECTED]> wrote:
>
>> Mike's tutorials while great in most regards ... when parsing XML
>> recommend the
>> use of GetElementsByTagName far more than is reasonable... or
>> efficient.
>> Say you are finding the points lines and polys in a GML
>> you call that three times it iterates the entire file every time... if
>> you instead iterate
>> through the children of a single parent you can do the same thing in
>> one pass
>>
>> GetElementsByTagName has uses but as THE recommended method.. ummmm,
>> no.
>>
>
> Using a compiled, built-in function like getElementsByTagName is much
> more efficient than interpreted JavaScript parsing with regular
> expressions.
> With nesting, one can confine getElementsByTagName to
> just the children of particular node.
How?
getElementsByTagName has no only immediate children clause..
starting at the outer most node in the tree the first pass checks not
just the children
but the childrens children and there children and there children etc...
even when the base children
dont match.. it still has to go all the way to the final nodes... for
its matching..
tracking the childnodes and matching with a switch does not involve
regular expression based testing see
the switch below...
for (var ln = 0; ln < node.childNodes.length; ln++) {
var nextn = node.childNodes.item(ln);
var nn = nextn.nodeName;
var nv = nextn.nodeValue;
switch (nn) {
}
> It can be done in a single
> pass.
If you have no inclination of preserving the structure in the XML
and only have one tagName to search on. it is indeed one pass...
In KML with folders in documents and folders within those etc...
. for example... asked to grab all the folders.. has to look through
the entire tree... and will do so even if when there is nothing
you are looking for down that branch tree...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---