GPX Parser for Java?


Are there any Java libraries for parsing GPX files? I need to parse many GPX files into our own data structure (our own database).


After some research, there is really no Java API/Lib for parsing GPX files, but I found a nice approach for parsing it using JAXB

Using this Tutorial:

1. Download GPX 1.0 and 1.1 Schema file (xsd)
2. Generate Java File from it using Eclipse Plugin
3. Init JAXBContext with package name of generated GPX java files (mine was "topografix.gpx.schema10")
4. Parse GPX File

JAXBContext jc = JAXBContext.newInstance("topografix.gpx.schema10");
Unmarshaller unmarshaller = jc.createUnmarshaller();
Gpx root = (Gpx) unmarshaller.unmarshal(new File("sample.gpx"));
List<Trk> tracks = root.getTrk();