嗨,我正在使用以下语句

    SELECT * FROM rss WHERE url="http://xml.weather.yahoo.com/forecastrss/SPXX0239_c.xml"


我得到了5天预报的数据,其中包含日期,图标,温度和文本,这很棒。但是我想获取其他信息,例如风寒,日出/日落,感觉像温度。我在请求中看不到它们??

这是我的数据回调

    window['wCallback_2'] = function(data) {
// Get todays weather forecast
     var info = data.query.results.item.forecast[0];
     var code = info.code;
$('#wData_current .wDate_d').append('<TD>' + info.date) + '</TD>';
    $('#wData_current .wDay_d').append('<TD>' + info.day) + '</TD>';
    $('#wData_current .wIcon_d').append('<TD> <img src="http://l.yimg.com/a/i/us/we/52/' + code + '.gif" width="80" height="80" title="' + info.text + '" /> </TD>');
$('#wData_current .wText_d').append('<TD>' + info.text + '</TD>');
    $('#wData_current .wHigh').append('<TD>' + info.high + '&deg;' + u + '</TD>');
    $('#wData_current .wLow').append('<TD>' + info.low + '&deg;' + u + '</TD>');


};

最佳答案

rss表仅提供<item>元素内部的内容。由于RSS是纯老式XML,因此可以使用xml表。

SELECT * FROM xml
WHERE url="http://xml.weather.yahoo.com/forecastrss/SPXX0239_c.xml"
AND itemPath="rss.channel.*"


将为您提供data对象,其结构如下:

{
 "query": {
  …
  "results": {
   "title": "Yahoo! Weather - Lanzarote, SP",
   …
   "location": { … },
   "units": { … },
   "wind": {
    "chill": "19",
    "direction": "20",
    "speed": "32.19"
   },
   "atmosphere": { … },
   "astronomy": {
    "sunrise": "7:29 am",
    "sunset": "8:19 pm"
   },
   "image": { … },
   "item": {
    "title": "Conditions for Lanzarote, SP at 8:59 pm WEST",
    "lat": "28.95",
    "long": "-13.6",
    "link": … ,
    "pubDate": "Mon, 15 Apr 2013 8:59 pm WEST",
    "condition": { … },
    "description": … ,
    "forecast": [ … ],
    "guid": { … }
   }
  }
 }
}


要获取日出时间,可以使用data.query.results.astronomy.sunrise

关于javascript - YQL天气声明未显示某些对象,例如日出,日落和风寒,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16018339/

10-13 07:51