T
T
tsypa2013-12-03 13:25:55
PHP
tsypa, 2013-12-03 13:25:55

The Yandex Weather API parser does not return image-v3 (xml, php). Why?

The code that outputs everything is -

<?php
$xml = 'http://export.yandex.ru/weather-ng/forecasts/32150.xml';  //адрес

$rss = simplexml_load_file($xml); //пыдыщ

foreach ($rss->fact as $fact)
{
      $temp = $fact->temperature; //выводим температуру
      $type = $fact->weather_type; //выводим тип
      $pic = $fact->image-v3; //выводим пикчакод
      echo $temp;
      echo '<br>';
      echo $type;
      echo '<br>';
      echo $pic;

}
?>

Only for some reason image-v3 is not displayed , but it is very necessary. Why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene Mosyukov, 2013-12-03
@tsypa

Instead $fact->image-v3use$fact->{'image-v3'}

M
Melkij, 2013-12-03
@melkij

If you are writing something, then at least turn on error output.
PHP is telling you that there is no such image element, and that the v3 constant is unknown to it. But you don't hear him. And that would clearly tell you which direction to dig. And they would have come with the specific question "how to refer to the image-v3 element?" instead.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question