GianCarlo, >i'm experimenting with jquery and xml. >I really can't understand the difference between $.ajax and $.get > >If you bought the book 'learning jquery', for xml parsing they always >use, or suggest to use (in the examples, but i may wrong) the $.get >method to retrieve the contents of an xml file. > >Why/*??*/ if i use $.get('http://www.corriere.it/rss/ultimora.xml', >function etcetera...) and try to access the 'item' text nothing >happens? > >$(document).ready(function(){ > $('#news-feed').each(function(){ > $('this').empty(); > $.get('ultimora.xml',function(data){ > $('/rss//item').each(function(){ > var titolo = $('title', this).text(); > alert(titolo) NOTHING >HAPPENS!!!!!!!!!!!!!!!!!! > }) > }) > > > }) > >});
The selectors you're using in the 2 examples are drastically different. The fact that you're getting no alert means one of two things: 1) You're getting a JS error 2) Your selector isn't returning any results. What happens if you change your selector from: $('/rss//item') To $('/rss//item', data) ??? If that doesn't work, try: $('item', data) The above selector matches what you're doing in your second sample code. -Dan