[jQuery] Parsing XML using jQuery

2008-01-29 Thread step kapusta

Thanks, David! :)

Your example helped me a lot to find a solution! The problem was
somewhere other.

That xml file is generateв with PHP-script. But forget to send the
right header using header(Content-Type: text/xml; charset=utf-8);
before XML contents output! Realy stupid mistake!


[jQuery] Parsing XML using jQuery

2008-01-28 Thread step kapusta

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
id1/id
addressVarvarka, 1/address
city_id1/city_id
  /building
  building
id2/id
addressNikolskaya, 1/address
city_id2/city_id
  /building
  building
id3/id
addressVarvarka, 3/address
city_id3/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(););
});