On Jan 19, 8:24 am, Black Fog <[email protected]> wrote:
> hi there,
>
> a simple question of xml processing through js !
>
> always worked with the gm examples, looking like that:
>
> "GDownloadUrl("somexmlstuff", function(data)
> {
> var xml = GXml.parse(data);
> var markers =
> xml.documentElement.getElementsByTagName("marker");
> for (var i = 0; i < markers.length; i++)
> {
> var x= markers[i].getAttribute("x");
> var y= markers[i].getAttribute("y");
> ..."
>
> worked fine, assuming, that the xml-file only consists of "empty"
> nodes, that means all information is stored within the attributes like
> that:
>
> "<markers>
> <marker x="stuffhere" lat="-10" lng="-74" y="stuffthere"/>
> ..."
>
> now i am looking for some help and isnpiration ;-)
>
> how the js code (that reads in the xml file and make js variables
> fromt the xml nodes) has to be written, if i am using a xml file like
> that:
>
> "<markers>
> <marker>
> <x>stuffhere</x>
> <y>stuffthere</y>
> </marker>
> <marker>
> ...
> </marker>
>
> need some example gm links or js tutorials.
>
> sorry for this simple sounding question, but i'm stucked in the
> moment.
GXml.value() returns the text content of those nodes in a browser
independent way.
This should get that content:
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++)
{
var x = GXml.value(markers[i].getElementsByTagName("x")[0]);
var y = GXml.value(markers[i].getElementsByTagName("y")[0]);
*** UNTESTED ***
Note that x and y will be strings and you probably will need to
convert them to numbers (parseFloat is one way).
-- Larry
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---