我正在尝试使用jQuery解析xml。我可以获得标题,描述,但无法从media:content读取img url。我已经尝试使用item.media.content.url XML-
<item>
<title>None</title>
<link>https://www.ip.com</link>
<description>Mohahah</description>
<guid>files</guid>
<pubDate>Mon, 11 Mar 2019 12:57:06 +0100</pubDate>
<dc:creator>TT</dc:creator>
<media:content type="image/jpeg" url="files/images/.jpg">
<media:credit scheme="urn:ebu">rant</media:credit>
<media:description></media:description>
</media:content>
</item>
代码
function loadXML (xml_url, url, color, wcolor ) {
jQuery(function() {
jQuery.getFeed({
url: xml_url,
success: function(feed) {
var html = '';
for(var i = 0; i < feed.items.length; i++) {
var item = feed.items[i];
html +='<article class="white-panel" style="background-color:#' + color + '">'
+ '<h5 style="color:#' + wcolor + '">' + url + '</h5>'
+ item.media.url
+'<h4><a href="' + item.link + '" target="_blank" rel="noopener noreferrer" >' + item.title + '</a></h4>'
+ '<a href="' + item.link + '" target="_blank" rel="noopener noreferrer" >' + item.description + '</a>'
+ '</article>'
}
jQuery('#pinBoot').append(html);
}
});
});
}