I'm trying to isolate lat/lon points in xml file to array. I am getting hung up on pushing the lat/lon child nodes text to the array. Ideally I would like the array to read as:
point 1 = lat1, lon1
point 2 = lat2, lon2
Here's what I have so far:
$.ajax({ type: "GET", url: "points.xml", dataType: "xml", success: function (xml) { //find each TP var areaPlots = $(xml).find('plot_area').each(function () { $(this).find('area').each(function () { var areas = $(this); $(areas).find('point').each(function () { var points = $(this); $(points).find('lat_num').each(function () { var latitude = $(this).text(); $(points).find('lon_num').each(function () { var longitude = $(this).text(); }) }) }) }) //end of success function } XML:
<plot_area> <area> <point> <lat_num>42.00861</lat_num> <lon_num>-94.00351</lon_num> </point> <point> <lat_num>43.00921</lat_num> <lon_num>-89.00024</lon_num> </point> <point> <lat_num>02.008427</lat_num> <lon_num>-74.99588</lon_num> </point> </area> </plot_area> How do I push each point's lat/lon pair to an array?
No comments:
Post a Comment