Google Weather APIに問題があります。このスクリプトhttp://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/をしばらく使用していますが、以前はこのエラーが発生しました:
警告:simplexml_load_file()[function.simplexml-load-file]://www.google.com/ig/api?weather=bermuda:2:パーサーエラー:タグの開始と終了の不一致:メタ行1と/homeのHEAD 3行目の/webmx04/public_html/weather/widgetlive1.php
警告:simplexml_load_file()[function.simplexml-load-file]:3023行目の/home/webmx04/public_html/weather/widgetlive1.phpに移動しました
警告:simplexml_load_file()[function.simplexml-load-file]:^3行目の/home/webmx04/public_html/weather/widgetlive1.php
警告:simplexml_load_file()[function.simplexml-load-file]://www.google.com/ig/api?weather=bermuda:6:パーサーエラー:タグの開始と終了の不一致:HEAD行1と/homeのHTML 3行目の/webmx04/public_html/weather/widgetlive1.php
警告:simplexml_load_file()[function.simplexml-load-file]:3行目の/home/webmx04/public_html/weather/widgetlive1.phpにあります
警告:simplexml_load_file()[function.simplexml-load-file]:^3行目の/home/webmx04/public_html/weather/widgetlive1.php
警告:simplexml_load_file()[function.simplexml-load-file]://www.google.com/ig/api?weather=bermuda:7:パーサーエラー:/ home/webmx04のタグHTML行1のデータが途中で終了しました3行目の/public_html/weather/widgetlive1.php
警告:simplexml_load_file()[function.simplexml-load-file]:3行目の/home/webmx04/public_html/weather/widgetlive1.phpにあります
警告:simplexml_load_file()[function.simplexml-load-file]:^3行目の/home/webmx04/public_html/weather/widgetlive1.php
致命的なエラー:4行目の/home/webmx04/public_html/weather/widgetlive1.phpにある非オブジェクトのメンバー関数xpath()を呼び出す
誰か助けてくれませんか
私のコード:
<?
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=bermuda');
$information = $xml->xpath("/xml_api_reply/weather/forecast_information");
$current = $xml->xpath("/xml_api_reply/weather/current_conditions");
$forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
?>
<html>
<head>
<title>Google Weather API</title>
</head>
<body>
<div id="widget-wrapper"><!-- start widget-wrapper-->
<div class="weather"><!-- start weather-->
<h2><a href="/section/weather" title="More on Weather" target="_top">Current Weather</a></h2>
<a href="/section/weather" target="_top"><img src="<?= 'http://www.rgbdahosting.com' . $current[0]->icon['data']?>" alt="More on Weather"?></a>
<span class="condition">
<a href="/section/weather" title="More on Weather" target="_top"><H4><?= $current[0]->temp_f['data'] ?>°F</H4>
<p><?= $current[0]->condition['data'] ?></p></a>
</span>
</div><!-- end weather-->
</div> <!-- end widget-wrapper-->
</body>