I am may have bitten off more then I chew but I am trying to parse an xml report from the noaa. The problem I am having is getting the attributes to pick up right in the parse. I may be going about this the complete wrong way. Please advise.
link of the xml file:
http://www.weather.gov/forecasts/xml...=rhm&pwwa=pwwa
Code for parsing the start and end times and the high and low temperature. This is not working, and I still have alot more to parse.
PHP Code:
$objDOM = new DOMDocument();
$objDOM->load("weather.xml"); //make sure path is correct
$note = $objDOM->getElementsByTagName("time-layout");
$temp_max = $objDOM->getElementsByTagName("temperature type=\"maximum\"");
$temp_min = $objDOM->getElementsByTagName("temperature type=\"minimum\"");
// for each note tag, parse the document and get values for
// tasks and details tag.
while ($i < 7) {
foreach( $note as $value )
{
$start_time = $value->getElementsByTagName("start-valid-time");
$start_times = $start_time->item($i)->nodeValue;
}
foreach( $note as $value )
{
$end_time = $value->getElementsByTagName("end-valid-time");
$end_times = $end_time->item($i)->nodeValue;
}
foreach( $temp_max as $value )
{
$temp_m = $value->getElementsByTagName("value");
$temp_max = $temp_m->item($i)->nodeValue;
}
foreach( $temp_min as $value )
{
$temp_mi = $value->getElementsByTagName("value");
$temp_mini = $temp_mi->item($i)->nodeValue;
}