I am trying to read XML elements that have a "-" in the name. The feed can be found at http://forecast.weather.gov/MapClick.php?lat=42.19774&lon=-121.81797&FcstType=dwml In my last question I was just trying to read any of them. reading a XML feed with '-' in some of the element names Now I am trying to read a particular one(other than the first) and I am getting stumped again.
This will get me the first time-layout and the first start-valid-time.
$time = $xml->data->{'time-layout'}->{'start-valid-time'};
I am after the second time-layout and I want to read through the attributes of the start-valid-time elements.
Below is a way that I have found that works. What I have done below cannot be the correct way to go about this. How should a person normally go about doing this?
Thanks.
$time = $xml->data->{'time-layout'};
$time2= $time[1]->{'start-valid-time'};
$count= 14;
for ($i = 0; $i <=$count ; $i++)
{
echo $time2[$i]->attributes();
print "<br>\n";
}