0

我对 RSS 雅虎天气预报有疑问。

我的案例:如何在 rss yahoo 天气预报中获取温度?

我的代码:我循环:

$current = $item->xpath('yweather:condition');<br>
 $forecast = $item->xpath('yweather:forecast');<br>
end loop

{$forecast[0]['day']} - {$forecast[0]['date']} -  {$forecast[0]['text']}. High: {$forecast[0]['high']} Low: {$forecast[0]['low']} || Code :{$forecast[0]['code']}

但因为{$forecast[0]['temp']}不工作。

4

1 回答 1

0

在 Yahoo Forecast 上,“temp”标签仅显示当天。

<yweather:condition text="Mostly Cloudy" code="26" temp="57" date="Tue, 29 Nov 2005 3:56
      pm PST"></yweather:condition>

您应该更改此代码以显示当前温度:

{$current[0]['temp']}

此外,如果您想显示下一天的温度,您应该只使用“高”和“低”标签。检查示例:

      <yweather:forecast day="Tue" date="29 Nov 2005" low="45" high="62" text="Mostly Cloudy"
      code="27"></yweather:forecast>
  <yweather:forecast day="Wed" date="30 Nov 2005" low="52" high="60" text="Mostly Cloudy"
      code="28"></yweather:forecast>
于 2015-05-28T09:50:30.583 回答