<?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 返回标签的内容。问题是我不需要该内容,我需要标签内的内容。我需要属性code、temp、text。我如何用我的实际代码做到这一点?谢谢
前标签内容:
<yweather:condition text="Partly Cloudy" code="30" temp="30" date="Fri, 16 Jul 2010 8:30 am AST" />