shadkeene
03-03-2012, 11:05 PM
Here's my script:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL|E_STRICT);
// script: csv_to_xml.php
// description: retrieves csv file of recreation site data and converts to xml
// altered to grab snow depth from tripcheck xml data
// author: Shad Keene
// date: 3/2/2012
$file = "http://www.greenandtheblue.com/weather/roadtest.xml";
$data = @file_get_contents($file);
$xml_file_data = new SimpleXMLElement($data);
echo '<pre>';
print_r($xml_file_data);
echo '</pre>';
$i = 0;
while ($xml_file_data->weatherReports->weatherReport[$i]->location->locationName != ''){
if (preg_match("/LK OF THE WOODS/", $xml_file_data->weatherReports->weatherReport[$i]->location->locationName)) {
echo"found lake of the woods";
}
$i++;
}
?>
I'm trying to get locationname tags to key in on certain locations, but it's giving errors. I've tried some different things, but nothing has worked. I'm just trying to get wired in to the way this xml is organized and how to access the various elements. I've taken a look at a few tutorials, but they seemed too basic.
Thanks for any help!
S
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL|E_STRICT);
// script: csv_to_xml.php
// description: retrieves csv file of recreation site data and converts to xml
// altered to grab snow depth from tripcheck xml data
// author: Shad Keene
// date: 3/2/2012
$file = "http://www.greenandtheblue.com/weather/roadtest.xml";
$data = @file_get_contents($file);
$xml_file_data = new SimpleXMLElement($data);
echo '<pre>';
print_r($xml_file_data);
echo '</pre>';
$i = 0;
while ($xml_file_data->weatherReports->weatherReport[$i]->location->locationName != ''){
if (preg_match("/LK OF THE WOODS/", $xml_file_data->weatherReports->weatherReport[$i]->location->locationName)) {
echo"found lake of the woods";
}
$i++;
}
?>
I'm trying to get locationname tags to key in on certain locations, but it's giving errors. I've tried some different things, but nothing has worked. I'm just trying to get wired in to the way this xml is organized and how to access the various elements. I've taken a look at a few tutorials, but they seemed too basic.
Thanks for any help!
S