1

您好,我正在使用该语句

    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>');

};

4

1 回答 1

1

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.

于 2013-04-15T21:38:37.993 回答