Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:28:18+00:00 2026-06-10T04:28:18+00:00

I’ve this php script that loads google weather from google API. <?php //Weather Forecast

  • 0

I’ve this php script that loads google weather from google API.

<?php

      //Weather Forecast icon and temperature from google weather API

      $setYourLanguage = "en"; // Possibilities: "en" - english; "ru" - russian; "ka" - georgian;
      //WEATHER, read google XML weather forecast
      $URL = "http://www.google.com/ig/api?weather=".$myCity."&hl=".$setYourLanguage."";

      $dataInISO = file_get_contents($URL);
      $dataInUTF = mb_convert_encoding($dataInISO, "UTF-8", "ISO-8859-2"); //fix Google's API UTF-8 bug
      $xml = simplexml_load_string($dataInUTF); 

      $current = $xml->xpath("/xml_api_reply/weather/current_conditions");
      $iconData = str_replace("/ig/images/weather/", "weather/",  $current[0]->icon['data']);
      $iconData = str_replace(".gif", ".png", $iconData);

?>

But sometimes page doesn’t load and I get error in apache2 logs:

[Thu Aug 23 12:04:16 2012] [error] [client ::1] PHP Warning:  simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in /Library/WebServer/Documents/wordpress/wp-content/themes/directorypress/homepage-structure.php on line 23
[Thu Aug 23 12:04:16 2012] [error] [client ::1] PHP Warning:  simplexml_load_string(): Unsupported API in /Library/WebServer/Documents/wordpress/wp-content/themes/directorypress/homepage-structure.php on line 23
[Thu Aug 23 12:04:16 2012] [error] [client ::1] PHP Warning:  simplexml_load_string(): ^ in /Library/WebServer/Documents/wordpress/wp-content/themes/directorypress/homepage-structure.php on line 23
[Thu Aug 23 12:04:16 2012] [error] [client ::1] PHP Fatal error:  Call to a member function xpath() on a non-object in /Library/WebServer/Documents/wordpress/wp-content/themes/directorypress/homepage-structure.php on line 25
[Thu Aug 23 12:05:57 2012] [error] [client ::1] What

Any ideas why this is happening? My theory is that it cannot connect correctly to URL and fails in this way… but why is page loading stopped? Is there any way to avoid this error? and allow page to load fully?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:28:20+00:00Added an answer on June 10, 2026 at 4:28 am

    If SimpleXml fails to load the XML, the value of the variable $xml is false and not an instance of type SimpleXMLElement. That is, what the error message said:

    [Thu Aug 23 12:04:16 2012] [error] [client ::1] PHP Fatal error: Call to a member function xpath() on a non-object in /Library/WebServer/Documents/wordpress/wp-content/themes/directorypress/homepage-structure.php on line 25

    So you should check against that before accessing a function on the object.

    if ($xml) {
          $current = $xml->xpath("/xml_api_reply/weather/current_conditions");
          $iconData = str_replace("/ig/images/weather/", "weather/",  $current[0]->icon['data']);
          $iconData = str_replace(".gif", ".png", $iconData);
    }
    

    Then your page will load completely, even if the XML load from the webservice fails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.