嗨我一直有谷歌天氣api有問題的問題警告:simplexml_load_string()[function.simplexml-load-string]:實體:第2行:解析器錯誤....simplexml加載谷歌天氣api prooblem
我試圖使用主要作者的腳本(認爲這是我編輯的腳本),但我仍然有這個錯誤我嘗試了2 //komunitasweb.com/2009/09/showing-the-weather-with- PHP和 - 谷歌全天候-API/
和
//tips4php.net/2010/07/local-weather-with-php-and-google-weather/
奇怪的部分是有時它修復自己然後再次回到我已經使用它幾個月的錯誤現在沒有任何問題,這只是昨天發生。也作者的演示頁面正在工作,但我有相同的確切代碼,請幫助。
這是我的地盤http://j2sdesign.com/weather/widgetlive1.php
@Mike我加了你的代碼
<?
$xml = file_get_contents('http://www.google.com/ig/api?weather=jakarta'); if (! simplexml_load_string($xml)) { file_put_contents('malformed.xml', $xml); }
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=jakarta');
$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");
?>
並提出了錯誤的清單,但我似乎無法看到錯誤原因它一直在修復自己然後再回到錯誤
這裏是文件的內容
<?php include_once('simple_html_dom.php'); // create doctype $dom = new DOMDocument("1.0");
// display document in browser as plain text
// for readability purposes //header("Content-Type: text/plain");
// create root element
$xmlProducts = $dom->createElement("products");
$dom->appendChild($xmlProducts);
$pages = array( 'http://myshop.com/small_houses.html', 'http://myshop.com/medium_houses.html', 'http://myshop.com/large_houses.html') foreach($pages as $page) { $product = array(); $source = file_get_html($page); foreach($source->find('img') as $src) { if (strpos($src->src,"http://myshop.com") === false) { $product['image'] = "http://myshop.com/$src->src"; } } foreach($source->find('p[class*=imAlign_left]') as $description) { $product['description'] = $description->innertext; } foreach($source->find('span[class*=fc3]') as $title) { $product['title'] = $title->innertext; } //debug perposes! echo "Current Page: " . $page . "\n"; print_r($product); echo "\n\n\n"; //Clear seperator } ?>
確定現在它的工作希望它保持這樣 – cooldude 2011-04-07 14:02:16
錯誤又回來了,請幫助感謝 – cooldude 2011-04-07 14:11:04
即使這樣一個不工作//www.ankitsharma.info/blog/weather-widget-using-google- weather-api我正在使用作者腳本http://j2sdesign.com/wg/wg/weatherg/documentation-and-example/這是我的託管問題嗎? – cooldude 2011-04-07 14:28:57