XML (GPX)¶
The native GPX format, conforming to the GPX 1.1 specification.
Saving to file¶
Getting XML as string¶
Pretty printing¶
By default, XML output is formatted with indentation. Disable it via Config:
PHP
use phpGPX\Config;
$gpx = new phpGPX(new Config(prettyPrint: false));
$file = $gpx->load('input.gpx');
$file->save('compact.gpx', phpGPX::XML_FORMAT);
Namespaces¶
Extension namespaces are included automatically when the file contains extensions. For example, a file with Garmin TrackPointExtension will include:
XML
<gpx xmlns="http://www.topografix.com/GPX/1/1"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"
...>
Creator attribute¶
The creator attribute is set from $gpxFile->creator. If not set, it defaults to the phpGPX library signature: