FYI yes. That is about right.
This is what I have done:
var xml = GXml.parse(request.responseText);
idD = xml.documentElement.getElementsByTagName("data_id");
latD = xml.documentElement.getElementsByTagName("latitude");
lonD = xml.documentElement.getElementsByTagName("longitude");
for (var i = 0; i < latD.length; i++) {
lat = latD[i].childNodes[0].nodeValue;
lon = lonD[i].childNodes[0].nodeValue;
id = idD[i].childNodes[0].nodeValue;
// Do some processing here
}
On Jan 19, 1:44 pm, "[email protected]" <[email protected]>
wrote:
> On Jan 19, 8:24 am, Black Fog <[email protected]> wrote:
>
>
>
> > hi there,
>
> > a simple question ofxmlprocessing through js !
>
> > always worked with the gm examples, looking like that:
>
> > "GDownloadUrl("somexmlstuff", function(data)
> > {
> > varxml= 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 thexml-file only consists of "empty"
> > nodes, that means all information is stored within the attributes like
> > that:
>
> > "<markers>
> > <markerx="stuffhere" lat="-10" lng="-74" y="stuffthere"/>
> > ..."
>
> > now i am looking for some help and isnpiration ;-)
>
> > how the js code (that reads in thexmlfile and make js variables
> > fromt thexmlnodes) has to be written, if i am using axmlfile 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
-~----------~----~----~----~------~----~------~--~---