如何使用jquery解析具有相同标签名称的yahoo天气api数据

时间:2012-09-10 13:11:02

标签: javascript android jquery-ui cordova xml-parsing

我正在使用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")代码

我的问题是:如何使用循环获得两个不同的值?

1 个答案:

答案 0 :(得分:1)

您可以使用each()

$(v).find("forecast").each(function(i) {
    alert($(this).attr('day'));
})

循环并获取值。我在这里已经提醒过了。