Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:28:27+00:00 2026-06-02T19:28:27+00:00

am learning javascript and not at a great rate, am trying to use the

  • 0

am learning javascript and not at a great rate, am trying to use the code to create a google map v3 api with searchable locations which load from an xml file.

Ran into a problem, many infact, but here is this one: I can not access the data in the xml file, i have used an example and tried to adjust it via reading and trying different code but to no success.

It is not accessing the data using my xml file, this is my xml format with the js code below:

    <markers style="MEDIUM">
       <marker>
         <title>McDonalds</title>
         <lat>55.5452</lat>
         <lng>34.3755</lng>
         <markerId>0</markerId>
         <countryCode>GB</countryCode>
         <address>Somewhere in London</address>
         <description>Get a free toy with every happy meal!</description>
       </marker>
    </markers>

This is the JS from my html file.

downloadUrl("london.xml", function(doc) {
            var xmlDoc = xmlParse(doc);
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");

            for (var i = 0; i < markers.length; i++) {
             // obtain the attribues of each marker
              var lat = parseFloat(markers[i].getElementsByTagName("lat"));
              var lng = parseFloat(markers[i].getElementsByTagName("lng"));
              var point = new google.maps.LatLng(lat,lng);

              var description = markers[i].getElementsByTagName("description");
              var title = markers[i].getElementsByTagName("title");
          alert(title);
              // create the marker
              var marker = createMarker(point,title,description);
            }
        alert(i);

I imagine it is something very simple such as linking the nodes, but I can not figure it out and thought some help or advice would save me some sanity, thanks guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:28:29+00:00Added an answer on June 2, 2026 at 7:28 pm

    Well, it is hard to say definitely where all the problems are… However, the first problem I can see is that you are trying to getElementsByTagName from documentElement but you need to take it from xmlDoc:

    var markers = xmlDoc.getElementsByTagName("marker");
    

    Then, you are trying to convert NodeList object to float. It should be redone to:

    var lat = parseFloat(markers[i].getElementsByTagName("lat")[0].textContent);
    var lng = parseFloat(markers[i].getElementsByTagName("lng")[0].textContent);
    

    Next, I believe description and title are stored in the textContent of the first nodes with the corresponding names. So,

    var description = markers[i].getElementsByTagName("description")[0].textContent;
    var title = markers[i].getElementsByTagName("title")[0].textContent;
    

    And don’t forget to check the right format of your XML file (including <?xml ...?> header, etc.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are starting to create an application using JavaScript and HTML5 which will use
I do not know javascript right now but I am planning on learning it.
So, I am learning Javascript while playing white Google Calendar APIs and I just
I have looked on Google, and everywhere in the forums. Just learning JavaScript, so
I'm learning Javascript, and here's what I'm trying to do... <body> <select name=selTitle id=titles>
Here is my following tutorial code from Learning PHP MYSQL and Javascript by OReilly.
When I write client side code, I use HTML/CSS/JavaScript and lately jQuery to both
I'm learning JavaScript. However, it's not so convenient to do some experiments. You have
Started learning javascript yesterday at CodeAcademy and decided I could actually write code. Just
I'm just beginning learning javascript and jQuery and need some help. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.