[jQuery] Parsing XML using jQuery
Hi, Some hours that I don't understand why this basic Xml parsing with JQuery doesn't work: $(document).ready(function() { var xml = '?xml version=1.0 encoding=utf-8? rootpHello World!/p/root'; alert($(p, xml).text()); }); I get an empty string, instead of the expected Hello World! I had a look to a similar previous post http://groups.google.com/group/jquery-en/browse_thread/thread/fc60b77f884e6866/85cbd666774c6780) , but this didn't help me to get the revelation.
[jQuery] Parsing XML using jQuery
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
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();); });