views:

65

answers:

1

I try to get the lat and lon's from a gpx file (GPS XML). When I do (snippet): $res = $xml->xpath('//*'); I get the full content returned. When I try to narrow down like this: $res = $xml->xpath('//rte'); I get nothing: array(0) { }. Even when the tag(s) exists. Actually whatever I try to fill in after // other then * it returns nothing. Have been trying for hours...

+1  A: 

You should use the correct namespace (Maybe "http://www.topografix.com/GPX/1/1"?) in your node test.

As example:

$xml = simplexml_load_file($URI);
$xml->registerXPathNamespace('gpx', 'http://www.topografix.com/GPX/1/1');
$res = $xml->xpath('//gpx:rte');
Alejandro
This works. Now I start to understand what's going on...thanks a lot for the quick reply.-Patrick
Patrick
@Patrick: You are wellcome.
Alejandro