Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : AttValue: " or ' expected in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : attributes construct error in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : Couldn't find end of Start Tag html line 2 in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : Extra content at the end of the document in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in googleWeather->request_data() (line 41 of /.../sites/all/modules/google_weather/google_weather.inc).

Comments

damiankloip’s picture

Status: Active » Postponed (maintainer needs more info)

You need to provide more info about how you invoked this error. Just the error is not enough because we won't know how to reproduce.

damiankloip’s picture

Title: Bug report » parser error : AttValue: " or ' expected
Prague man’s picture

Visit the front page (To Prague/) and I see this error.

And in Reports (last error message) I see this issue:

TYPE	php
DATE	Thursday, August 9, 2012 - 15:30
USER	admin
LOCATION	http://to-prague.eu/
REFERRER	
MESSAGE	Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in googleWeather->request_data() (line 41 of /..y/www/sites/all/modules/google_weather/google_weather.inc).
SEVERITY	warning
damiankloip’s picture

Thats the same data as you have provided. What settings? language? locations? does it work for a common one like London? that sort of thing.

Prague man’s picture

Now I noticed that I do not remove the location settings here: /admin/config/services/google_weather/locations
when I click on Remove, nothing happens, its only see Ajax wheel for a while, but that's it all.

I have set Prague as location, language english. Try to with London. It is hard to locate the error because the error message is displayed only sometimes.

ckrina’s picture

I'm getting this error too sometimes, but I reload the page and it disappears.
I've the site i 4 languages: english, french, spanish and catalan. Working in a local installation (MAMP). Location: 25752 (Catalonia, Spain).
Moreover, can't delete/remove locations as @Prague man.
Next time I get it I'll try to provide more information.
Connection timeout *: 10
Temperature unit system *: Celsius
Block cache lifetime: 1 hour

worldwidecraig’s picture

I get the same error.
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error : AttValue: " or ' expected in googleWeather->request_data() (line 43 of /home/content/41/6771941/html/sites/all/modules/google_weather/google_weather.inc).

It only comes up occassionally and if you refresh the page it dissappears. Settings are default location Australia 4025

ckrina’s picture

I'm still getting this error. When it appears, it prints the "Data could not be requested from google weather service." message in the block. But other web services load correctly, like Addthis or Facebook Like button (loading number of people liked it).
I think the error isn't the connection because if I turn it off directly (clearing cache and running cron after that) I only get the message "Data could not be..." but the error doesn't appear.

worldwidecraig’s picture

Yes Im still getting it too, I was told if you put an @ in front of $xml = simplexml_load_string ($data); eg
@$xml = simplexml_load_string ($data); it will show the error to the users at least. I will try it out.
Also your "Data could not be requested from google weather service." is a message you can edit in configure google weather section under google weather settting. I changed mine to weather is currently not available refresh your page to display.

Prague man’s picture

I tried to create custom code and its worked fine, without errors. You can see it on this website about Prague. Here si my code:

<?php
$urlr = "http://www.google.com/ig/api?weather=Prague&hl=en";
$xml_str = @file_get_contents($urlr);
if($xml_str) {
$xml = simplexml_load_string($xml_str);
$current_cond = $xml->weather->current_conditions;
?>
  <div class="weather current">
    <div class="location"><strong>Prague</strong></div>
    <div class="weather-icon">
      <img src="<?php print "http://www.google.com".$current_cond->icon['data']; ?>" alt="current icon" />
    </div>
    <div class="weather-info forecast-info ">
      <div class="day"><?php print t("Now"); ?></div>
      <div class="temp"><?php print   $current_cond->temp_c['data']; ?>°C</div>
      <div class="condition"><?php print  $current_cond->condition['data']; ?></div>
      <div class="wind"><?php print  $current_cond->wind_condition['data']; ?></div>
    </div>
    <div class="clear-block"></div>
  </div>
  
    <div class="separator">
      <?php print t("Weather forecast"); ?>
    </div>

<?php $id=1; ?>
  <?php foreach ($xml->weather->forecast_conditions as $forecast): ?>
    <div class="weather forecast forecast-<?php print $id; ?>">
      <div class="weather-icon float-left">
        <img src="<?php print  "http://www.google.com".$forecast->icon['data']; ?>" alt="forecast icon" />
      </div>
      <div class="weather-info forecast-info">
        <div class="day"><?php print $forecast->day_of_week['data']; ?></div>
        <div class="temp"><?php print round(($forecast->high['data']-32)*(5/9)); ?>°C | <?php print round(($forecast->low['data']-32)*(5/9)); ?>°C</div>
        <div class="condition"><?php print $forecast->condition['data']; ?></div>
      </div>
      <div class="clear-block"></div>
    </div>
  <?php 
$id++;
endforeach; 
}
else {
print "<p>Weather is not available, the server with Google weather was not responding, please reload the page.</p>";
}
?>

and CSS:

div#block-block-5 div.weather {
     background-color: #E9E9E9;
     clear: none;
     display: block;
     float: left;
     margin: 0px 3px 3px 0px;
     min-width: 140px;
}

div#block-block-5 div.weather div.weather-info {
     border: medium none;
     float: none;
     min-height: 79px;
     width: auto;
}

div#block-block-5 div.weather img {
     float: left;
     margin: 2px 2px 2px;
}

div#block-block-5 div.weather div.day {
     font-size: 16px;
}

div#block-block-5 div.weather div.temp {
     font-size: 16px;
}

div#block-block-5 div.weather div.condition {
     color: #D85715;
     font-size: 12px;
}

div#block-block-5 div.current {
     background-color: #FDF4F2;
     min-height: 162px;
}

div#block-block-5 div.current div.location {
     border-bottom: 4px solid #D8D800;
     color: #004080;
     margin: 0px;
     padding: 0px 0px 0px 5px;
}

div#block-block-5 div.current div.weather-icon img {
     float: left;
     margin: 0px 3px 3px;
     padding: 0px;
     width: auto;
}

div#block-block-5 div.current div.weather-info {
     float: none;
     width: auto;
}

div#block-block-5 div.current div.weather-info div.day {
     font-size: 22px;
     margin: 0px;
     padding: 0px;
}

div#block-block-5 div.current div.weather-info div.temp {
     font-size: 30px;
     margin: 0px;
     padding: 0px;
}
pio.fernandes’s picture

Yeah... bummer, I got that too. Google blocked me...

Google
Sorry...
We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
See Google Help for more information.

My link is http://www.google.com/ig/api?hl=pt-pt&weather=Mafra, and I added var_dump($url); t see it, in line 35 of google_weather.inc, after $url = $api . urlencode($this->location->location);

jboese’s picture

This is occurring I believe when Google has placed a rate limit on your IP address.

Viewing the address the XML is fetched from within a browser shows the following:

Google
Sorry...
We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.

See Google Help for more information.

radimklaska’s picture

1) This Google API (e.g. http://www.google.com/ig/api?weather=Prague&hl=en ) is not official for public. It was used in iGoogle to get the weather information. & iGoogle will be retired. (See http://support.google.com/websearch/bin/answer.py?hl=en&hlrm=cs&answer=2... ) So I gues this is the real reason behind.

2) I was really hoping for some rate limit (we can cache the result...), but got the "We're sorry..." page even on first request.

Is there any alternative google based API for weather we can switch to?

npugliese’s picture

RdeBoer’s picture

Title: parser error : AttValue: " or ' expected » Google has quietly killed its weather API

Re-title in line with #14...

Prague man’s picture

ok. I use this code as alternative from best weather forecast - Yr.no :
Look at the demo on my site about Prague here.

<?php
$urlr = "http://www.yr.no/place/Czech_Republic/Prague/Prague/varsel.rss";
$xml = simplexml_load_string(file_get_contents($urlr));
if($xml) {
?>
<div class="weather current">
    <div class="location"><h2>Prague weather</h2></div>
    <div class="weather-icon">
      <img src="<?php print $xml->channel->item[2]->enclosure["url"]; ?>" alt="current icon" />
    </div>
    <div class="weather-info forecast-info">
      <div class="day"><?php print $xml->channel->item[2]->title; ?></div>
      <div class="condition"><?php print  $xml->channel->item[2]->description; ?></div>
    </div>
</div>
    <div class="weather forecast">
      <div class="weather-icon float-left">
        <img src="<?php print $xml->channel->item[6]->enclosure["url"]; ?>" alt="forecast icon" />
      </div>
      <div class="weather-info forecast-info">
        <div class="day"><?php print $xml->channel->item[6]->title; ?></div>
        <div class="condition"><?php print $xml->channel->item[6]->description; ?></div>
      </div>
    </div>
    <div class="weather forecast">
      <div class="weather-icon float-left">
        <img src="<?php print $xml->channel->item[10]->enclosure["url"]; ?>" alt="forecast icon" />
      </div>
      <div class="weather-info forecast-info">
        <div class="day"><?php print $xml->channel->item[10]->title; ?></div>
        <div class="condition"><?php print $xml->channel->item[10]->description; ?></div>
      </div>
<span>More about <a href="http://www.yr.no/place/Czech_Republic/Prague/Prague/long.html" target="_blank">Prague weather you can find here</a></span>
    </div>
  <?php 
}
else {
print "<p>Weather is not available, the server with Yr.no weather was not responding, please reload the page.</p>";
}
?>
trudog’s picture

i think there is a problem with the calls to google's api. if you clear the logs and refresh the page that contains the google wether block you will see at least 50 logs for xml error. if you print the $data, you will see google's message:

We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.

i believe the modules makes to many calls at once.