我有我一直在使用這個腳本http://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/了一段時間,現在與谷歌的天氣API的問題,但早些時候,我得到這個錯誤:谷歌的天氣API問題
Warning: simplexml_load_file() [function.simplexml-load-file]: //www.google.com/ig/api?weather=bermuda:2: parser error : Opening and ending tag mismatch: meta line 1 and HEAD in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: 302 Moved in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]:^in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: //www.google.com/ig/api?weather=bermuda:6: parser error : Opening and ending tag mismatch: HEAD line 1 and HTML in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]:^in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: //www.google.com/ig/api?weather=bermuda:7: parser error : Premature end of data in tag HTML line 1 in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Warning: simplexml_load_file() [function.simplexml-load-file]:^in /home/webmx04/public_html/weather/widgetlive1.php on line 3
Fatal error: Call to a member function xpath() on a non-object in /home/webmx04/public_html/weather/widgetlive1.php on line 4
誰能幫我謝謝
我代碼:
<?
$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>
查看源代碼不匹配意味着代碼未在關閉或關閉的不當位置 – 2011-04-06 15:13:30
您好,感謝您的回覆,但是您通過上述代碼添加的不匹配的含義,您能看到我在做什麼錯誤,我只是不知道什麼是錯的演示在http://komunitasweb.com/2009/09/showing-the-weather-with-php-and-google-weather-api/工作正常,但當我複製粘貼它在我的託管它只是給了我錯誤 – Brian 2011-04-06 16:27:50
由於某種原因它是修復自己我很無知發生了什麼 – Brian 2011-04-06 16:51:57