So I haven't any experience on xml reading with php, I've been doing some research,read some tutorials but there's one thing I'd like to make sure of. Now I have this xml code below (file.xml):
<location code="TB0023">
<temp unit="F">15.8</temp>
<US>Intermittent clouds</US>
</location>
<location code="YG0023">
<temp unit="F">23</temp>
<US>Mostly Clear</US>
</location>
So the way I access for example temp on location code="TB0023" is this:
$open = simplexml_load_file('file.xml');
echo $open ->location[0]->temp;
Now I've unsuccessfully trying to make it a bit more readable by doing something like this(like associative arrays somehow):
$open = simplexml_load_file('file.xml');
echo $open ->location[code="TB0023"]->temp;
So is there any way to use that identifier TB0023 to retreive data from that specific location, without using indexes 0 1 2 3...
Thank you.