GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
String could not be parsed as XML  XML
Forum Index -> General
Author Message
krypton



Joined: 30/10/2007 09:36:34
Messages: 1
Offline

Hi,

I get sometimes the following error message when i use the geonames webservice. When i reload the page its all ok.

Content-type of the website: text/html;charset=iso-8859-1

Code:
 Error Message:
 Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' 
 in mysite.php:71 Stack trace: #0 
 mysite.php(71): SimpleXMLElement->__construct('') #1 {main} 
 thrown in mysite.php on line 71
 


Line 71: $urlinhalt=@file_get_contents($adresse);

Code:
 $adresse="http://ws.geonames.org/postalCodeSearch?postalcode=".rawurlencode(utf8_encode(trim($_POST["plz"])))."&country=".$country."&maxRows=1";
 		
 $urlinhalt=@file_get_contents($adresse);
 		
 $urlinhalt = $urlinhalt;
 		
 $xml = @new SimpleXMLElement($urlinhalt);
 		
 $anzahl=$xml->totalResultsCount;
 $land_kuerzel=$xml->code->countryCode;
 $bundesland=utf8_decode($xml->code->adminName1);
 $gemeinde=utf8_decode($xml->code->adminName2);
 $longitude=$xml->code->lng;
 $latitude=$xml->code->lat;
 


HELP please

THANK YOU!

Max
marc



Joined: 08/12/2005 07:39:47
Messages: 4499
Offline

It could be a problem with the free server being overloaded some times. If it is overloaded it throws a timeout exception.

Regards

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team