我正在使用 yahoo 天气 api,我想获取预报详细信息,但 XML 显示了两个这样的节点
<yweather:forecast day="Thu" date="23 May 2013" low="32"
high="44" text="Clear" code="31"/>
<yweather:forecast day="Fri" date="24 May 2013" low="31"
high="44" text="Sunny" code="32"/>
现在我如何选择第二个请帮助获取我正在使用此代码的节点,我只获取第一个节点值。
$myxml=new SimpleXMLElement("http://weather.yahooapis.com/forecastrss?w=$woeid[0]&u=c",NULL,TRUE);
$ab=$myxml->children();
$ad=$ab->channel->item->children('yweather',true)->forecast->attributes();
$fhigh=(string) $ad->high;
$flow=(string) $ad->low;
$ftemptype=(string) $ad->text;
$fdate=(string) $ad->date;
我得到 $flow 作为 32 和 $fdate 作为 2013 年 5 月 23 日