all-sensors.xml
Posted: Sun Sep 25, 2011 5:10 pm
I upgraded from version 4.6t to 4.8a.
From then on I got problems in viewing XML-data: Now with "http://192.xxxxx/meteograph.cgi?text=allxml" I can't open the xml-data any more. I get the error message "XML-Verarbeitungsfehler: nicht wohlgeformt ....". I wrote a script to read out this file with simplexml-load. There, I also get the error message mentioned above: The problem are the german "Umlaute". How can I fix my script to read the new XML-format in Meteohub Version 4.8a?
Here the script:
<html>
<head>
<meta http-equiv='Content-Language' encoding='utf-8' content='de-ch'>
<title>Wetterstation beim Tinguely Museum, Basel, Bergalingerstrasse, Schweiz</title>
</head>
<body>
<?php
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://meteo.square7.ch/all-sensors.xml');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($content);
} else {
$filename = 'http://meteo.square7.ch/all-sensors.xml';
$xml = simplexml_load_file($filename);
}
echo 'Auslesen des Files all-sensors.xml';
for ($k=0, $to=count($xml->data); $k<$to; ++$k)
{
echo '<br />', '<br />';
for ($m=0, $sensorzahl=count($xml->data[$k]->item); $m<$sensorzahl; ++$m)
{
$sensor = $xml->data[$k]->item[$m][sensor];
$cat = $xml->data[$k]->item[$m][cat];
$unit = $xml->data[$k]->item[$m][unit];
echo $xml->data[$k][timeframe], ' -- ' .$k, ' - ' .$m, ' -- ' .$sensor, ' // ' .$cat, ' // ' .$unit, ' // ';
echo $xml->data[$k]->item[$m], '<br />';
}
}
?>
</body>
</html>
Greetings from Basel
Thomas
From then on I got problems in viewing XML-data: Now with "http://192.xxxxx/meteograph.cgi?text=allxml" I can't open the xml-data any more. I get the error message "XML-Verarbeitungsfehler: nicht wohlgeformt ....". I wrote a script to read out this file with simplexml-load. There, I also get the error message mentioned above: The problem are the german "Umlaute". How can I fix my script to read the new XML-format in Meteohub Version 4.8a?
Here the script:
<html>
<head>
<meta http-equiv='Content-Language' encoding='utf-8' content='de-ch'>
<title>Wetterstation beim Tinguely Museum, Basel, Bergalingerstrasse, Schweiz</title>
</head>
<body>
<?php
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://meteo.square7.ch/all-sensors.xml');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($content);
} else {
$filename = 'http://meteo.square7.ch/all-sensors.xml';
$xml = simplexml_load_file($filename);
}
echo 'Auslesen des Files all-sensors.xml';
for ($k=0, $to=count($xml->data); $k<$to; ++$k)
{
echo '<br />', '<br />';
for ($m=0, $sensorzahl=count($xml->data[$k]->item); $m<$sensorzahl; ++$m)
{
$sensor = $xml->data[$k]->item[$m][sensor];
$cat = $xml->data[$k]->item[$m][cat];
$unit = $xml->data[$k]->item[$m][unit];
echo $xml->data[$k][timeframe], ' -- ' .$k, ' - ' .$m, ' -- ' .$sensor, ' // ' .$cat, ' // ' .$unit, ' // ';
echo $xml->data[$k]->item[$m], '<br />';
}
}
?>
</body>
</html>
Greetings from Basel
Thomas