I am requesting to external api and it gives the below response. It is in the XML Format.
Here is the way , how i am using to request
$('#trigger').click(function()
{
var token = '662d3330f192b4af77d5eef8de58f7e8c01a12a7';
var location = $('#Address').val();
var lat = $('#latitude').val();
var long = $('#longitude').val();
$.ajax({
url: 'https://api.quickblox.com/data/Location',
data: {
token:'2100d8b55d4a389470b849de9378093dcda12903'
},
method: 'get',
success: function(xml) {
console.log(xml);
}
});
});
And Here is the Response i got from the server.
#document
<data type="array" class_name="Location" skip="0" limit="0">
<Location>
<_id>558a8325535c1246bb00d5c5</_id>
<_parent_id>test-api</_parent_id>
<created-at type="integer">1435140901</created-at>
<lat type="float">11.0270643</lat>
<location>Avarampalayam, Coimbatore, Tamil Nadu, India</location>
<long type="float">76.9830277</long>
<updated-at type="integer">1435140901</updated-at>
<user-id type="integer">3566216</user-id>
</Location>
<Location>
<_id>558a83dd535c12843900dbbe</_id>
<_parent_id>test-api</_parent_id>
<created-at type="integer">1435141085</created-at>
<lat type="float">11.0310806</lat>
<location>Mettupalayam Bus Stand, Mettupalayam Road, Tatabad, Coimbatore, Tamil Nadu, India</location>
<long type="float">76.9525282</long>
<updated-at type="integer">1435141085</updated-at>
<user-id type="integer">3566216</user-id>
</Location>
<Location>
<_id>558b8d97535c129bd3000e04</_id>
<_parent_id>test-api</_parent_id>
<created-at type="integer">1435209111</created-at>
<lat nil="true"/>
<location>Hyderabad, Telangana, India</location>
<long nil="true"/>
<updated-at type="integer">1435209111</updated-at>
<user-id type="integer">3566216</user-id>
</Location>
<Location>
<_id>558b8d81535c12aadd046730</_id>
<_parent_id>test-api</_parent_id>
<created-at type="integer">1435209089</created-at>
<lat type="float">13.1067448</lat>
<location>Avadi, Tamil Nadu, India</location>
<long type="float">80.0969511</long>
<updated-at type="integer">1435209089</updated-at>
<user-id type="integer">3566216</user-id>
</Location>
<Location>
<_id>558b86ad535c123883005741</_id>
<_parent_id>test-api</_parent_id>
<created-at type="integer">1435207341</created-at>
<lat type="float">10.3673123</lat>
<location>Dindigul, Tamil Nadu, India</location>
<long type="float">77.9802906</long>
<updated-at type="integer">1435207341</updated-at>
<user-id type="integer">3566216</user-id>
</Location>
<Location>
<_id>558b8f72535c126322011368</_id>
<_parent_id>test-api</_parent_id>
<created-at type="integer">1435209586</created-at>
<lat type="float">12.977357</lat>
<location>Bangalore City Junction, Gubbi Thotadappa Road, Majestic, Bengaluru, Karnataka, India</location>
<long type="float">77.57077</long>
<updated-at type="integer">1435209586</updated-at>
<user-id type="integer">3566216</user-id>
</Location>
</data>
Here is the snapshot of the image
How can i get the _id, created_at fields from the response ?
I tried like this in the success function
success: function(xml) {
console.log(xml);
$(xml).filter('data').find('Location').each(function()
{
var id = $(this).find('_id').text();
var parentId = $(this).find('_parent_id').text();
var createdAt = new Date($(this).find('created-at').text());
var lat = parseFloat($(this).find('lat').text());
});
}
But i am not getting anything. How can i do this ?