get attribute of xml in php

Posted: 19th June 2012 by urfusion in php
Tags: , , , , , ,

get attribute of xml in php

this is the attribute structure of xml

 [ForecastDay0] => SimpleXMLElement Object
 (
 [@attributes] => Array
 (
 [FDay] => 0
 [Date] => 2008-11-11T00:00:01.930
 [Name] => Tuesday
 )
 And this is the code to retrieve attribute
 foreach($xml->Forecasts->$weather->attributes() as $a => $b) {
 $FDay = $b;
 }
 echo "$FDay";