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 7925251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:12:48+00:00 2026-06-03T18:12:48+00:00

I have a function that pulls data out of an XML file. I am

  • 0

I have a function that pulls data out of an XML file. I am trying to store that data in an array so I can loop through the array and filter it. So when “Time_of_Day” (From a dropdown menu) = “Time_of_Day” value in the array, my array will filter.

Right now I just need help building the array. Then I will try to understand how to loop through it and find the value for “Time_of_Day”.

Here is my function to pull out data from the XML file. Right now my array is only storing the name values (mainly because I dont know what I am doing).

var markerfilter = new Array();
MYMAP.placeMarkers = function(filename) {
$.get(filename, function(xml){
    $(xml).find("marker").each(function(){
        var name = $(this).find('name').text();
        var address = $(this).find('address').text();
        var address2 = $(this).find('address2').text();
        var Meeting_Type = $(this).find('Meeting_Type').text();
        var Time_of_Meeting = $(this).find('Time_of_Meeting').text();
        var Day_of_Meeting = $(this).find('Day_of_Meeting').text();
        var Open_Meeting = $(this).find('Open_Meeting').text();
        var Wheelchair = $(this).find('Wheelchair').text();
        var ASL = $(this).find('ASL').text();
        var Comments = $(this).find('Comments').text();
        markerfilter.push(name);

        var MeetingType = document.getElementById("Meeting_Type");
        var type = MeetingType.options[MeetingType.selectedIndex].text;
        var DayofMeeting = document.getElementById("Day_of_Meeting");
        var day = DayofMeeting.options[DayofMeeting.selectedIndex].text;
        var TimeofMeeting = document.getElementById("Time_of_Meeting");
        var time = TimeofMeeting.options[TimeofMeeting.selectedIndex].text;

        // create a new LatLng point for the marker
        var lat = $(this).find('lat').text();
        var lng = $(this).find('lng').text();
        var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));

        // extend the bounds to include the new point
        MYMAP.bounds.extend(point);

        var marker = new google.maps.Marker({
            position: point,
            map: MYMAP.map
        });

        var infoWindow = new google.maps.InfoWindow();
        var html='<b><u>'+name+'</b></u><br />'+address2+'<br />'+address+'<br />'+Meeting_Type+',&nbsp'+Time_of_Meeting+',&nbsp'+Day_of_Meeting+'<br />Open Meeting:&nbsp'+Open_Meeting+'<br />Wheelchair Accessible:&nbsp'+Wheelchair+'<br />ASL:&nbsp'+ASL+'<br />Comments:&nbsp'+Comments;
        google.maps.event.addListener(marker, 'click', function() {
            infoWindow.setContent(html);
            infoWindow.open(MYMAP.map, marker);
        });
        MYMAP.map.fitBounds(MYMAP.bounds);
        });
    });
}

THe XML file that is created looks like this:

<markers>
    <marker>
        <name>AA at Greek Food</name>
        <address>292 Danforth Avenue  Toronto, ON</address>
        <address2>Asteria</address2>
        <Meeting_Type>AA</Meeting_Type>
        <Time_of_Meeting>Late</Time_of_Meeting>
        <Day_of_Meeting>Wednesday</Day_of_Meeting>
        <Open_Meeting>Yes</Open_Meeting>
        <Wheelchair>Yes</Wheelchair>
        <ASL>Yes</ASL>
        <Comments>Greek food is good.</Comments>
        <lat>43.677322</lat>
        <lng>-79.353729</lng>
    </marker>
    <marker>
        <name>CA over Sushi</name>
        <address>18 Jane Street, Toronto, ON</address>
        <address2>ASA Sushi</address2>
        <Meeting_Type>CA</Meeting_Type>
        <Time_of_Meeting>Early</Time_of_Meeting>
        <Day_of_Meeting>Monday</Day_of_Meeting>
        <Open_Meeting>No</Open_Meeting><Wheelchair>Yes</Wheelchair>
        <ASL>No</ASL>
        <Comments>CA eating Sushi.</Comments>
        <lat>43.649773</lat>
        <lng>-79.484772</lng>
    </marker>
<markers>
  • 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-03T18:12:55+00:00Added an answer on June 3, 2026 at 6:12 pm

    You probably want to do something like this:

    $(xml).find("marker").each(function() {
        markerfilter.push({
            name: $(this).find("name").text(),
            address: $(this).find("address").text()
            // and so on
        });
    });
    console.log(markerfilter);​
    
    // the markerfilter array will look like:
    // 
    // [
    // {name: "name1", address: "address1", /*...*/},
    // {name: "name2", address: "address2", /*...*/},
    // .
    // .
    // .
    // ]
    

    Edit

    Looking at your XML, I think it is much easier to create an associative array like this:

    $(xml).find("marker").each(function() {
        var markerdata = {};
        $(this).children().each(function() {
            markerdata[this.tagName] = $(this).text();
        });
        markerfilter.push(markerdata);
    });
    console.log(markerfilter);
    

    demo here

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

Sidebar

Related Questions

I'm using Joomla 1.5. I have created a custom component that pulls data out
My trying to make an Ajax call to a PHP function that pulls out
I have a function that pulls rows from a database, the content->id and content->type
We have a function that pulls the date from the first 8 characters of
In my Java code I have function that gets file from the client in
I have a function that outputs an XML string: <expensesAC> <cashflow> <month>6</month> <cash>300</cash> <projected>null</projected>
I have an array that I'm appending to in a loop: array_push($obj->{$type.'listings'}, $listing); The
I have a script that pulls in meta data from a list of URL's
So I have a PHP backend that pulls some data from SQL, let's just
have a Grails domain object that has a custom static function to grab data

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.