I have a problem, couldn't solve it for a long time. I have the following XML file, returned from ajax:
<?xml version="1.0" encoding="utf-8"?> <root> <buildingsList> <building> <id>1</id> <address>Varvarka, 1</address> <city_id>1</city_id> </building> <building> <id>2</id> <address>Nikolskaya, 1</address> <city_id>2</city_id> </building> <building> <id>3</id> <address>Varvarka, 3</address> <city_id>3</city_id> </building> </buildingsList> </root> And I wanna get the value of 'city_id' element of the each element 'building'. I do the following: $('/root/buildingsList/building', xml).each(function() { alert($("city_id", this).text();); }); But it doesn't work as I expect. Am I wrong? I'm completely tired looking for a mistake. I've tried the following also, but it gave the same result: $('building', xml).each(function() { alert($("city_id", this).text();); });