我有以下代码来解析雅虎天气信息:
$xml = simplexml_load_file('http://weather.yahooapis.com/forecastrss?w=868274&u=c');
$weatherInfo = $xml->channel->item->description;
$imagePattern = '/src="(.*?)"/i';
preg_match($imagePattern, $weatherInfo, $matches);
$imageSrc = $matches[1];
$degreesPattern = '/.*?, (\d+) C/i';
preg_match($degreesPattern, $weatherInfo, $matches);
$degrees = $matches[1];
echo $degrees;
如何修改解析器以适用于负度数?
谢谢你。