G
Google Maps Slovenija
I'm working with Google Maps API and I have trouble understanding this
problem of mine which is Javascript related. I will be as clear and
short as possible. Any help will be much appreciated!
We have two different XML files:
XML file 1:
---------------
<markers>
<marker name="Hooters" type="restaurant"> </marker>
<marker name="McDonalds" type="restaurant" </marker>
<marker name="Eddys" type="bar" </marker>
</markers>
XML file 2:
--------------
<markers>
<marker>
<name> Hooters </name>
<type> restaurant </type>
</marker>
<marker>
<name> McDonalds</name>
<type> restaurant </type>
</marker>
<marker>
<name> Eddys </name>
<type> bar </type>
</marker>
</markers>
Now I write the Javascript code for parsing XML file 1 or XML file 2:
GDownloadUrl("markers.xml", function(data) {
var xml = GXml.parse(data);
var markers =
xml.documentElement.getElementsByTagName("marker");
followed by a for loop for retrieving info like this:
for (var i = 0; i < markers.length; i++) {
var name = markers.getAttribute("name");
var type = markers.getAttribute("type");
Can someone please explain to me what is the structure of the markers
variable for the XML file 1 and XML file 2 example. I would like to
know how the array markers is structured! Is there any simple code to
view it, so I can understand better how to access its components!
Thanks in advance!
Peter from Slovenija
problem of mine which is Javascript related. I will be as clear and
short as possible. Any help will be much appreciated!
We have two different XML files:
XML file 1:
---------------
<markers>
<marker name="Hooters" type="restaurant"> </marker>
<marker name="McDonalds" type="restaurant" </marker>
<marker name="Eddys" type="bar" </marker>
</markers>
XML file 2:
--------------
<markers>
<marker>
<name> Hooters </name>
<type> restaurant </type>
</marker>
<marker>
<name> McDonalds</name>
<type> restaurant </type>
</marker>
<marker>
<name> Eddys </name>
<type> bar </type>
</marker>
</markers>
Now I write the Javascript code for parsing XML file 1 or XML file 2:
GDownloadUrl("markers.xml", function(data) {
var xml = GXml.parse(data);
var markers =
xml.documentElement.getElementsByTagName("marker");
followed by a for loop for retrieving info like this:
for (var i = 0; i < markers.length; i++) {
var name = markers.getAttribute("name");
var type = markers.getAttribute("type");
Can someone please explain to me what is the structure of the markers
variable for the XML file 1 and XML file 2 example. I would like to
know how the array markers is structured! Is there any simple code to
view it, so I can understand better how to access its components!
Thanks in advance!
Peter from Slovenija