$(function () { $.ajax({ url: '../rss_read.php', xmlType: 'xml', success: function (xml) { var row = 0; var data = []; var nodeName; var output = $('#feed'); $(xml).find('item').each(function () { data[row] = {}; $(this).children().each(function () { nodeName = $(this)[0].nodeName; if (nodeName == "dc:date") { nodeName = 'dcdate'; } data[row][nodeName] = {}; attributes = $(this)[0].attributes; for (var i in attributes) { data[row][nodeName][attributes[i].name] = attributes[i].value; } if (nodeName == "dcdate") { data[row]['dcdate']['text'] = $(this).text().substr(0, 10); } else { data[row][nodeName]['text'] = $(this).text(); } }); row++; }); for (i in data) { if (i >= 2) { continue; } var dateStr = data[i].dcdate.text; var imgStr = data[i].description.text.match(/src="(.*?)"/igm); var Feed = '
' + '' + '' + '

' + '' + data[i].title.text + '' + '

' + '' + '

' + data[i].description.text.substr(0, 50) + '…

' + '
'; $('#feed').append(Feed); } } }); });