我正在使用jquery来解析yahoo weather api xml的响应。
我的XML响应在这里:http://pastie.org/4695569
第41行和第41行42有两个标记名称yweather:forecast
,
解析XML的代码在http://pastie.org/4695573
我可以使用yweather:forecast
forecast_today_day:$(v).find("forecast").attr("day")
代码
我的问题是:如何使用循环获得两个不同的值?
答案 0 :(得分:1)
您可以使用each()
。
$(v).find("forecast").each(function(i) {
alert($(this).attr('day'));
})
循环并获取值。我在这里已经提醒过了。