<?php
$doc = new DOMDocument();
$doc->load('http://weather.yahooapis.com/forecastrss?p=VEXX0024&u=c');
$channel = $doc->getElementsByTagName("channel");
foreach($channel as $chnl)
{
$item = $chnl->getElementsByTagName("item");
foreach($item as $itemgotten)
{
$describe = $itemgotten->getElementsByTagName("description");
$description = $describe->item(0)->nodeValue;
echo $description;
}
}
?>
正如你所看到的是一个简单的脚本从上面的url返回标记的内容。问题是我不需要这些内容,我需要标签内的人。我需要的属性代码,临时,文本。我如何简单地使用我的实际代码?由于如何从PHP中的Yahoo Weather RSS获取标签“<yweather:condition>”?
防爆标签内容:
<yweather:condition text="Partly Cloudy" code="30" temp="30" date="Fri, 16 Jul 2010 8:30 am AST" />