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
2010-08-17 21:55:25
This works. Now I start to understand what's going on...thanks a lot for the quick reply.-Patrick
Patrick
2010-08-18 10:59:13
@Patrick: You are wellcome.
Alejandro
2010-08-18 12:37:22