get attribute of xml in php

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";

You may also like...

%d bloggers like this: