Hi,
I am trying to work with this xml page:
http://maps.google.com/maps/api/directions/xml?origin=m20%202nu&destination=m5%205hf&sensor=false
public function LoadXml(){
$xml = simplexml_load_file("http://maps.google.com/maps/api/directions/xml?origin=m20%202nu&destination=m5%205hf&sensor=false");
foreach ($xml->xpath('//distance') as $distance):
echo $distance->value->getName() . ": " .
$distance->value . "<br />";
endforeach;
echo "<BR>";
foreach($xml->xpath('//leg') as $address):
echo "The start address is: ".$address->
start_address.$address. "<br />";
echo "The end address is: ".$address->end_address.$address;
endforeach;
}
what this code does is echo out the following:
value: 102
value: 268
value: 701
value: 103
value: 4512
value: 275
value: 704
value: 1575
value: 64
value: 65
value: 1782
value: 313
value: 10464
The start address is: Manchester, Greater Manchester M20 2NU, UK
The end address is: Salford M5 5HF, UK
Now i don’t need ALL the values, i only need the total value which is 10464. So is there a way to display the last child, or the final value?
So all i want to show is value: 10464…
How can i access the final instance of the value?
Thanks again