Jump to content

how to solve: XML Parsing Error: no element found


plusnplus

Recommended Posts

Hi..

 

I try to get google weather info into my website.

when i try this code:

<?php
header("content-type: text/xml");
$xmlData = file_get_contents("http://www.google.com/ig/api?weather=new york");
echo $xmlData;
?>

i got error : XML Parsing Error: no element found

 

but when i directly type http://www.google.com/ig/api?weather=new york into the browser, it give me the xml file.

Any idea how to solve this problem?

 

Thanks for any reply/ help

 

Your browser automatically adds urlencoding for you, when you do it in PHP you need to add it manually, or use urlencode()

 

the solution to your problem would be:

<?php
header("content-type: text/xml");
$xmlData = file_get_contents("http://www.google.com/ig/api?weather=new%20york");
echo $xmlData;
?>

 

There's always more than one way to do something, though. :P

Hi pornophobic,

 

it is still give me the same error:

XML Parsing Error: no element found

 

it that possible the error because, my company block something in firewall?

 

but like i mention before i able to see without error if i type directly to browser(firefox):

http://www.google.com/ig/api?weather=new%20york

 

actually i try other weather api script from yahoo, still not show same error, but not if i put direct in browser.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.