Добрый день, недавно заказал скрипт парсинга погоды с xml. Собственно сам скрипт вот: <?php
function parseData(){
$content = file_get_contents("http://xml.meteoservice.ru/export/gismeteo/point/37.xml");
$xmlParser = new SimpleXMLElement($content);
return $xmlParser;
}
function getAttributes($xml){ $ret = array(); foreach($xml->attributes() as $key=>$value) { $ret[$key] = $value; } return $ret; }
$mmweather = parseData(); ?>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>gismeteo parser</title><!-- Bootstrap -->
<link href="/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<![endif]-->
</head>
<body>
<div class="container">
<h1>Wheather</h1>
<?php $town = getAttributes($mmweather->REPORT->TOWN) ?>
<h3>Town: <?php print urldecode($town["sname"]);?></h3>
<table class="table table-hover table-responsive">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($mmweather->REPORT->TOWN->FORECAST as $forecast) : ?>
<tr>
<?php $attr = getAttributes($forecast);?>
<td colspan="4"><?php print $attr["day"]; ?>.<?php print $attr["month"]; ?>.<?php print $attr["year"]; ?>
at <?php print $attr["hour"]; ?>:00</td>
</tr>
<tr>
<td><?php $temp = getAttributes($forecast->TEMPERATURE); ?> TEMPERATURE: <?php print $temp["min"];?> - <?php print $temp["max"];?></td>
<td><?php $press = getAttributes($forecast->PRESSURE); ?> PRESSURE: <?php print $press["min"];?> - <?php print $press["max"];?></td>
<td><?php $wind = getAttributes($forecast->WIND); ?> WIND: <?php print $wind["min"];?> - <?php print $wind["max"];?></td>
<td><?php $relwet = getAttributes($forecast->RELWET); ?> RELWET: <?php print $relwet["min"];?> - <?php print $relwet["max"];?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
/*print "<pre>";
print_r($mmweather);
print "</pre>";*/
?>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<!-- Include all compiled plugins (below), or include individual files as needed -->
</body>
</html>
</html> Я убрал все лишнее кроме php и получилось вот: function parseData(){
$content = file_get_contents("http://xml.meteoservice.ru/export/gismeteo/point/37.xml");
$xmlParser = new SimpleXMLElement($content);
return $xmlParser;
}
function getAttributes($xml){ $ret = array(); foreach($xml->attributes() as $key=>$value) { $ret[$key] = $value; } return $ret; }
$mmweather = parseData();
$town = getAttributes($mmweather->REPORT->TOWN)
print urldecode($town["sname"]);
foreach($mmweather->REPORT->TOWN->FORECAST as $forecast) :
$attr = getAttributes($forecast);
print $attr["day"]; .print $attr["month"]; . print $attr["year"];
at print $attr["hour"];
$temp = getAttributes($forecast->TEMPERATURE); TEMPERATURE: print $temp["min"]; - print $temp["max"]; $press = getAttributes($forecast->PRESSURE); PRESSURE: print $press["min"]; - print $press["max"]; $wind = getAttributes($forecast->WIND); WIND: print $wind["min"];- print $wind["max"]; $relwet = getAttributes($forecast->RELWET); RELWET: print $relwet["min"]; - print $relwet["max"];
endforeach; Но когда вставляю этот сниппет, то у меня вместо сайта белый экран. Подскажите что не так?
Синтаксис через онлайн чекер проверьте. Или просто в пхп файл скопируйте и запустите. Он и покажет ошибки если их вывод не отключён
Пишет что нету ошибок
Белый экран - 99.99% критическая ошибка php. Зайдите в core/config/config.inc.php и пропишите где-нибудь в начале ini_set('display_errors', 1); Если данная настройка не запрещена, то на странице вы увидите сообщение об ошибке.