How to solve: XML Parsing Error: no element found

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: How to solve: XML Parsing Error: no element found

Post by Jonah Bron »

1. Yes, that's what he meant; on your computer

3. :google: http://lmgtfy.com/?q=php+curl
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

Actually the script just can work without cURL installed right?
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

is there any way to check in phpinfo() function, wheter the setting is correct or not?
I still get nothing from:
<?php
header("content-type: text/xml");
$xmlData = file_get_contents("http://www.google.com/ig/api?weather=new%20york");
echo $xmlData;
?>

thanks for any help/ info
lalitchand
Forum Newbie
Posts: 5
Joined: Wed Jun 16, 2010 4:39 am

Re: How to solve: XML Parsing Error: no element found

Post by lalitchand »

This message comes when server doesn't return any result.

Thanks,
Lalit
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

lalitchand wrote:This message comes when server doesn't return any result.

Thanks,
Lalit
hm..., you mean my server or url link server?
if you mean my server, then how to configure it correctly? setting apache.conf ?

if you mean url link server, you are wrong. because when i type direct(http://www.google.com/ig/api?weather=new%20york) in browser it give me result(xml file)
lalitchand
Forum Newbie
Posts: 5
Joined: Wed Jun 16, 2010 4:39 am

Re: How to solve: XML Parsing Error: no element found

Post by lalitchand »

I mean your link server ..
There are two possibilities .. either your Apache server is not configured correctly ..or
if your Apache server is behind some proxy.. then bypass this proxy server..

Hope it helps ..

Thanks,
Lalit
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

lalitchand wrote:I mean your link server ..
There are two possibilities .. either your Apache server is not configured correctly ..or
if your Apache server is behind some proxy.. then bypass this proxy server..

Hope it helps ..

Thanks,
Lalit
Hi lalitchand,
yes, my apache server is behind some proxy.
How i bypass the proxy server?
I mean, where i should put the user id and password, in php script or apache conf ?
lalitchand
Forum Newbie
Posts: 5
Joined: Wed Jun 16, 2010 4:39 am

Re: How to solve: XML Parsing Error: no element found

Post by lalitchand »

Sorry for replying late..
you have to set proxy setting in your php file.

Code: Select all


curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_PROXY, "proxy_server");
curl_setopt($ch, CURLOPT_PROXYPORT, "port"); 

hope it helps.

Regards,
lalit
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

Hi lalitchand,

Thanks for try to help me.
is that curl in your script?
because i don't use curl in my php/ apache.
lalitchand
Forum Newbie
Posts: 5
Joined: Wed Jun 16, 2010 4:39 am

Re: How to solve: XML Parsing Error: no element found

Post by lalitchand »

Please refer this link for better clarity.
http://developer.yahoo.com/javascript/howto-proxy.html

you cannot get access or data from public server because of security violations.

This link shed light on this problem.

Hope it helps.

Cheers
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

now my problem is how to install curl in my php.
i did google, try and still no success.
here i get from googling:
-copy libeay32.dll and ssleay32.dll from the DLL folder of the PHP/ binary package to the SYSTEM folder of your Windows machine. (Ex: C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM) . Please also open you ?php.ini? file . (Ex: C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM) and
Change the line ?;extension=php_curl.dll?
To this ?extension=php_curl.dll?
-copy the libcurl.dll from the PHP program folder to C:\Windows\System32 and restart the Apache server
- i also have msvcr70.dll in my C:\WINNT\SYSTEM32


I can not see any info about curl in phpinfo()

Anyone have easy way/ guide to install curl ?
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

Hi lalitchand,

now i have curl in php.

how i combine this code:
header("content-type: text/xml");
$xmlData = file_get_contents("http://www.google.com/ig/api?weather=new%20york");
echo $xmlData;

with your code?
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_PROXY, "proxy_server");
curl_setopt($ch, CURLOPT_PROXYPORT, "port");

thanks for help me :)
lalitchand
Forum Newbie
Posts: 5
Joined: Wed Jun 16, 2010 4:39 am

Re: How to solve: XML Parsing Error: no element found

Post by lalitchand »

Code: Select all

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

function file_get_contents($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
// put here your proxy server ip
curl_setopt($ch, CURLOPT_PROXY, "http://172.18.65.22:80");
// put here your proxy server port
curl_setopt($ch, CURLOPT_PROXYPORT, 80); 
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
I think this script should run.
make sure curl is enabled ..
All d best

~Cheers
plusnplus
Forum Newbie
Posts: 20
Joined: Wed Jun 02, 2010 9:58 pm

Re: How to solve: XML Parsing Error: no element found

Post by plusnplus »

Hi lalitchand,

Thanks, it is work.
Post Reply