My exrate.xml look like
<ExrateList>
<DateTime>5/29/2011 8:54:12 PM</DateTime>
<Exrate CurrencyCode="AUD" CurrencyName="AUST.DOLLAR" Buy="21688.77" Transfer="21819.69" Sell="22201.6"/>
<Source>source name </Source>
</ExrateList>
Does anyone know how I can read xml and output data.
currency | buy | sale
I have
<?php
= simplexml_load_file("Service/Forex_Content.xml");
echo '<pre>';
print_r($xml);
echo '</pre>';
?>
SimpleXMLElement Object
(
[DateTime] => 5/29/2011 8:54:12 PM
[Exrate] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[CurrencyCode] => AUD
[CurrencyName] => AUST.DOLLAR
[Buy] => 21688.77
[Transfer] => 21819.69
[Sell] => 22201.6
)
)
How can I encode @ attributes to display data?
foreach ($xml as $value){
foreach ($value->@attributes as $key=>$val){
}
}
source
share