Getting started

The first thing you need to do is to add the gpxParser.jar file to your classpath. After this, you can use the main class GPXParser for various operations.

Parsing a gpx file

In order to parse a gpx file, you need to instantiate the GPXParser class, and then call parseGPX() method:

GPXParser p = new GPXParser();
FileInputStream in = new FileInputStream("inFile.gpx");
GPX gpx = p.parseGPX(in);

Writing a GPX object into a gpx file

In order to write a GPX object into a gpx file, you need to instantiate the GPXParser class, and then call writeGPX() method:

GPXParser p = new GPXParser();
FileOutputStream out = new FileOutputStream("outFile.gpx");
p.writeGPX(gpx, out);
out.close();

The GPX object

GPX object is the main java bean that holds the entire gpx structure. It has a list of Waypoints, Tracks and Routes that you can access from getWaypoints((), getRoutes() and getTracks() methods.

You can also add new Waypoints, Tracks and Routes, by calling addWaypoint(), addTrack() and addRoute() methods.