GPX Extensions

GPX format allows for all nodes to have a custom extension node, that can hold any type of information. Because the contents of the extensions nodes is customizable, and anyone can add whatever is needed for their particular needs, this information cannot be processed in a generic way, like the rest of the nodes, that are well defined.

GPXParser introduces a way for the extensions information to be parsed. In order to process the extensions nodes, one needs to know the exact information that is stored in there. The way this information is processed, falls into custom extension parsers. One only needs to create a new extension parser and then to add it to the GPXParser instance, in order to be used at the moment of parsing/writing.

Every gpx java bean object defines a way to store data found in extensions nodes. This data is specific to a custom parser.

Let's say, for example that we have the following information defined in an extensions node of a waypoint:


<wpt lat="42.438878" lon="-71.119277">

In order to get <myCustomName> node value we need to define a new custom parser that knows how to handle the current structure form the <extensions> node. For additional information on creating a custom parser, please see the Custom Parser page.

 After parsing this node, the Waypoint object that is created, will be propulated with the extensions information. we can call getExtensionData(MyCustomParser.getId()) in order to acces the processed information.

Note: getExtensionData() method returns an Object. It is your job to cast the value to whatever type is used by the Custom Parser.