They are more complete, they include icon code!
But they are not in rss format.
You can find more informations here: http://dd.meteo.ec.gc.ca/
I did a small code to add a simple block in one of my site, (some weather conditions where missing in the module and I didn't wanted to add them manualy...)

$fichier = 'http://dd.meteo.ec.gc.ca/citypage_weather/xml/QC/s0000635_f.xml';
$dom = new DOMDocument();
if (!$dom->load($fichier)) {
    die('Impossible de charger le fichier XML');
}
echo '<div id="meteoLienEC"><a href="http://www.meteo.gc.ca/city/pages/qc-147_metric_f.html" target="new">Environnement Canada</a>';
$currentConditions = $dom->getElementsByTagName('currentConditions');
foreach ($currentConditions as $item) {
    $condition = $item->getElementsByTagName('condition');
    if ($condition->length > 0) {
        echo  '<div id="meteoCondition" >'.$condition->item(0)->nodeValue.'</div>';
    } else {
        echo  '(sans titre)';
    }
       $temperature = $item->getElementsByTagName('temperature');
    if ($temperature->length >0) {
      echo '<div id="meteoTemperature" >'.$temperature->item(0)->nodeValue.'°C</div>';
    }
	
    $iconCode = $item->getElementsByTagName('iconCode');
    if ($iconCode->length > 0) {
        echo  '<div id="meteoIcon"><img id="meteoIconCode" src="ec-icons/'.$iconCode->item(0)->nodeValue.'.gif" ></div>';
    }
    


    
}

Comments

MathGosselin’s picture

My first script was loading the xml from EC each time, so I added a simple cache system.
The xml file is copied to ec/ (it needs to be writable) if it's older than one hour, all the icons are in ec/ec-icons/. When I will have more time I will make a module from it.

$ec_xml = 'http://dd.meteo.ec.gc.ca/citypage_weather/xml/QC/s0000635_f.xml';
$cache_xml = 'ec/s0000635_f.xml';
$cache_life = '3600'; //in seconds

$filemtime = @filemtime($cache_xml);  // return FALSE if file doesn't exist 
if (!$filemtime or (time() - $filemtime >= $cache_life)){
   if (!copy($ec_xml, $cache_xml)) {
    echo "failed to copy $cache_xml...\n";
	}
}else{
   
$dom = new DOMDocument();
if (!$dom->load($cache_xml)) {
    die('Impossible de charger le fichier XML');
}

$currentConditions = $dom->getElementsByTagName('currentConditions');
foreach ($currentConditions as $item) {
    
       $day = $item->getElementsByTagName('day');
	echo '<div id="meteoDate">'.$day->item(1)->nodeValue.' - ';
    $month = $item->getElementsByTagName('month');
	echo $month->item(1)->nodeValue.' - ';
    $year = $item->getElementsByTagName('year');
	echo $year->item(1)->nodeValue.'<br>';

       $temperature = $item->getElementsByTagName('temperature');
    if ($temperature->length >0) {
      echo '<b>Montréal</b> '.$temperature->item(0)->nodeValue.'°C<br>';
echo '<a id="meteoLienEC" href="http://www.meteo.gc.ca/city/pages/qc-147_metric_f.html" target="new">Environnement Canada</a></div>';
    }
	
$iconCode = $item->getElementsByTagName('iconCode');

    if ($iconCode->length > 0) {
        echo  '<div id="meteoIcon"><img id="meteoIconCode" src="ec/ec-icons/'.$iconCode->item(0)->nodeValue.'.gif" ></div>';
    }



    
}
}
aufumy’s picture

Hi MathGosselin, thanks for this, I did not know about the xml files.

Can you cache the files in the files directory instead of the module directory?

file_directory_path() can be used to find the files directory.

Can you please create a patch for your code contribution?
http://drupal.org/patch/create

MathGosselin’s picture

Hi,
I will have more time to look into that after the Holidays. For now it's not perfect but it's working. I plan to include that xml (http://dd.meteo.ec.gc.ca/citypage_weather/docs/site_list_en.html) to be able to select the city and xml feed from a list.
Thanks for your reply!

aufumy’s picture

It is a security risk to make directories writable outside of drupal's main files directory. Even then there is a security risk, but it is minimized, by the .htaccess that is created and managed by drupal.

I tried looking for an appropriate book page, but couldn't quite what I was looking for. Here are some general pages about permissions and the files directory.
http://drupal.org/node/244924
http://drupal.org/node/394704
http://drupal.org/node/34025
http://drupal.org/node/34028
http://drupal.org/node/202483