【发布时间】:2011-04-23 15:09:20
【问题描述】:
我有一个 xml 提要,我试图从中提取两个值。我将在下面粘贴基本的 xml 提要。
<aws:weather>
<aws:current-condition icon="http://deskwx.weatherbug.com/images/Forecast/icons/cond034.gif">Mostly Cloudy</aws:current-condition>
</aws:weather>
为了解析这个提要,我在 Javascript 中有以下内容:
$(document).ready(function(){
$.get('http://xmlfeed-with-private-api-access.xml', function(d){
$(d).find('weather').each(function(){
var $weatherinfo = $(this);
var winfo = $weatherinfo.find('current-condition').text();
var winformation = winformation += '<span>' + winfo + '</span>' ;
$('#sydinfo').append($(winformation));
$('.loadingPic').fadeOut(1400);
});
});
});
这可以很好地获取“多云”文本。但现在我无法形成一个声明来显示图标 url - 它位于标签本身 (http://deskwx.weatherbug.com/images/Forecast/icons/cond034.gif)
有人能帮忙在上面的js中附加一个语句来读取和显示这个值吗?
【问题讨论】:
标签: javascript jquery xml xml-parsing