I am trying to get some xml data into my web page using php. When I am placeing the url into a web browser it is showing some xml data. But when I am doing that from inside a php page it is returning some empty data.

The link is "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=GBP&ToCurrency=INR".

My code looks like -

<?php 
$url  = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=INR"; 

$xml = simplexml_load_file($url); 

print "<pre>"; 
var_dump($xml); 
print "</pre>"; 
?>

And it is returing -
bool(false)

PLEASE HELP ME

Recommended Answers

All 5 Replies

I copied your code into my own page and ran it and got a result with FF, IE and Chrome:

object(SimpleXMLElement)#1 (1) {
  [0]=>
  string(5) "52.82"
}

Strange...

Member Avatar for LastMitch

@anirban1087

But when I am doing that from inside a php page it is returning some empty data.

Read this

http://www.phpfreaks.com/tutorial/handling-xml-data

You're missing something in the xml file that's why it's not reading the data.

If you are having issues then can you post the code that display your xml.

I need to upload 100 XML files in php from a directory, how can I do that, please any Feedback.

Dilip

Member Avatar for diafol

@dilip

You're hijacking this thread. Start your own, as this topic is not related - or doesn't seem to be.

check to see if you are running php in safe mode. if not you may have allow_url_fopen turned off in your php.ini file. I believe that in order to do what you are trying to do that you need to have this option turned on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.