【问题标题】:Yahoo weather forecast - <yweather:forecast雅虎天气预报 - <yweather:forecast
【发布时间】:2014-11-20 16:33:51
【问题描述】:

我有这个代码

require('magpierss/rss_fetch.inc');
$url = 'http://weather.yahooapis.com/forecastrss?p=AUXX0013'
$rss = fetch_rss($url);
$title = $rss->items[0]['title'];
$description = $rss->items[0]['description'];

如何从这部分 xml 中获取数据,例如 (code="33" )

<yweather:forecast day="Thu" date="25 Sep 2014" low="43" high="57" text="Mostly Clear" code="33"/>

【问题讨论】:

  • 那么,你的问题是如何在 PHP 中解析 XML?
  • 我了解如何解析,但这部分有问题

标签: php yahoo weather


【解决方案1】:

当您要提取的数据不是普通 RSS 文档的一部分时,您不能使用用于解析 RSS 的库。

只需read the XML data,然后使用xpath 即可获取您需要的数据。

【讨论】:

    猜你喜欢
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    • 2013-10-25
    • 2013-02-28
    • 2018-09-17
    • 2014-05-13
    • 1970-01-01
    相关资源
    最近更新 更多