0

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

Edited by Dani: Formatting fixed

6
Contributors
5
Replies
8
Views
5 Years
Discussion Span
Last Post by R0bb0b
0

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...

0

@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.

1

@dilip

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

Edited by diafol

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.