Skip to content

Commit

Permalink
Merge pull request #5 from phbaer/master
Browse files Browse the repository at this point in the history
Change XML namespace names from (10,11) to (a,b)
  • Loading branch information
bastianonm committed Oct 28, 2016
2 parents daf11b4 + f9b94d9 commit db44ad4
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions wp-gpx-maps_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,11 @@ function parseXml($filePath, $gpxOffset, $distancetype)
if($gpx === FALSE)
return;

$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
$gpx->registerXPathNamespace('gpxtpx', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');

$nodes = $gpx->xpath('//trk | //10:trk | //11:trk');
$gpx->registerXPathNamespace('a', 'http://www.topografix.com/GPX/1/0');
$gpx->registerXPathNamespace('b', 'http://www.topografix.com/GPX/1/1');
$gpx->registerXPathNamespace('gpxtpx', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');

$nodes = $gpx->xpath('//trk | //a:trk | //b:trk');
//normal gpx

if ( count($nodes) > 0 )
Expand All @@ -232,11 +231,11 @@ function parseXml($filePath, $gpxOffset, $distancetype)

$trk = simplexml_load_string($_trk->asXML());

$trk->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
$trk->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
$trk->registerXPathNamespace('gpxtpx', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');
$trk->registerXPathNamespace('a', 'http://www.topografix.com/GPX/1/0');
$trk->registerXPathNamespace('b', 'http://www.topografix.com/GPX/1/1');
$trk->registerXPathNamespace('gpxtpx', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1');

$trkpts = $trk->xpath('//trkpt | //10:trkpt | //11:trkpt');
$trkpts = $trk->xpath('//trkpt | //a:trkpt | //b:trkpt');

$lastLat = 0;
$lastLon = 0;
Expand Down Expand Up @@ -498,7 +497,7 @@ function parseXml($filePath, $gpxOffset, $distancetype)

//gpx strange case

$nodes = $gpx->xpath('//rtept | //10:rtept | //11:rtept');
$nodes = $gpx->xpath('//rtept | //a:rtept | //b:rtept');
if ( count($nodes) > 0 )
{

Expand Down Expand Up @@ -581,9 +580,9 @@ function getWayPoints($gpxPath)
return $points;
}

$gpx->registerXPathNamespace('10', 'http://www.topografix.com/GPX/1/0');
$gpx->registerXPathNamespace('11', 'http://www.topografix.com/GPX/1/1');
$nodes = $gpx->xpath('//wpt | //10:wpt | //11:wpt');
$gpx->registerXPathNamespace('a', 'http://www.topografix.com/GPX/1/0');
$gpx->registerXPathNamespace('b', 'http://www.topografix.com/GPX/1/1');
$nodes = $gpx->xpath('//wpt | //a:wpt | //b:wpt');
global $wpdb;

if ( count($nodes) > 0 )
Expand Down Expand Up @@ -689,4 +688,4 @@ function date_getDecimals($date)



?>
?>

0 comments on commit db44ad4

Please sign in to comment.