I am trying to get curreny exchange rate from an API. Code as below
<?php
$return = file_get_contents("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22AEDUSD%22%29&env=store://datatables.org/alltableswithkeys");
$xml=simplexml_load_string($return) or die("Error: Cannot create object");
echo '<pre>'; print_r($xml);
?>
Above Code provides the XML
SimpleXMLElement Object
(
    [results] => SimpleXMLElement Object
        (
            [rate] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [id] => AEDUSD
                        )
                    [Name] => AED/USD
                    [Rate] => 0.2722
                    [Date] => 7/14/2015
                    [Time] => 7:17am
                    [Ask] => 0.2723
                    [Bid] => 0.2722
                )
        )
)
I would like to get Rate node value [Rate] => 0.2722 I tried below
<?php
    echo '<pre>'; print_r($xml->results->rate->Rate);
?>
It gives the result as below,
SimpleXMLElement Object
(
    [0] => 0.2722
)
How to get rid of the Object and take the value?
 
     
    