I have a object that creates simplexml_load_file();
$xmlPoland = simplexml_load_file('http://export.yandex.ru/weather-ng/forecasts/12375.xml');
echo "<pre>";
print_r($xmlPoland);
echo "</pre>";
I need to get the value of the [fact] temperature
(-9
).
How to make this?
This should work for you:
echo $xmlPoland->fact->temperature;
Output:
-9
If you need it from this part:
[fact] => SimpleXMLElement Object
(
[@attributes] => Array
(
[source] => forecast
)
[observation_time] => 2014-12-29T19:06:19
[uptime] => 2014-12-29T19:06:19
[temperature] => -9
[weather_condition] => SimpleXMLElement Object
(
[@attributes] => Array
(
[code] => mostly-clear
)
)
Also i would recommend you to take a look here: http://php.net/manual/en/function.simplexml-load-file.php
And as @superultranova suggested take a look here: http://php.net/manual/en/book.simplexml.php