XML:jQuery XML parsing come ottenere attributo elemento
<item>
<title>Some title</title>
<description>
<![CDATA[
Some description text Some description text Some description text Some description text Some description text Some description text
Some description text Some description text Some description text Some description text Some description text Some description text
Some description text Some description text Some description text Some description text Some description text Some description text
Some description text Some description text Some description text Some description text Some description text Some description text
]]>
</description>
<media:content isDefault="true" medium="image" url="http://sampledomain.com/image.jpg">
<media:title>Image title</media:title>
<media:description>Image description</media:description>
<media:thumbnail url="http://sampledomain.com/image.jpg" width="160" height="120" />
</media:content>
<wfw:commentRss>http://sampledomain.com/comment/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
sto recupero css da Ajax e nella funzione onSuccess mio codice è il seguente:
$(xml).find('item').each(function() {
var title = $(this).find('title').eq(0).text();
var url = $(this).find('content').attr('url');
// Printing url as undefined
alert(url);
console.log($(this).find('content');
});
Quello che voglio ottenere url contenuti attributo Sto ricevendo item figli (titolo, descrizione, contenuto, commentoRss e commenti) ma quando provo a ottenere $ (this) .find ('content') Non mi sta dando nulla Qualcuno può capire cosa sono io fare male? Grazie
var url = $ (this) .find ('content'). Attr ('url'). Val(); o prova a usare .text() spero che aiuti – Rafay