docs: function(err, result) {
          var data=[];
      
          // default route name if not present in XML
          var now=new Date();
          data.name= 'ParseGPX' + now.toISOString(); 
      
          // search for gpx tag
          if (result['gpx'] === undefined) {
              console.log ("Fatal: Not a GPX route/track file [no <gpx></gpx> tag]");
              return (-1);
          }
          // search for track tag
          if (result['gpx']["trk"] !== undefined) {
              // console.log ("track=%s", JSON.stringify(result['gpx']["trk"]));
              data = {
                  mode    : 'track',
                  name    : result['gpx']["trk"][0].name,
                  segment : result['gpx']["trk"][0]["trkseg"][0]['trkpt']
              };
          }
          // search for route tag
          if (result['gpx']["rte"] !== undefined) {
              //console.log ("route=%s", JSON.stringify(result['gpx']["rte"]));
              data = {
                  mode    :'route',
                  name    :result['gpx']["rte"][0].name,
                  segment :result['gpx']["rte"][0]["rtept"]
              };
          }
          if (data.mode === undefined) {
             console.log ("Fatal Not a valid GPX route/track file <trk>|<rte> tag");
             return (-1);
          }
      
          // provide a default name if nothing found in gpxfile
          if (data.name === undefined) {
              now= new Date();
              route.name = 'GGsimulator://' + opts.gpxfile + "/" + now.toISOString();
          } else {
              route.name = 'GGsimulator://' + data.name;
          }
      
          switch (data.mode) {
              case "track":
              var spd, crs, alt,dat;
              for (var trackpts in data.segment)  {
                  // console.log ("trackpts[%s]=%s", trackpts, JSON.stringify(data.segment[trackpts]));
                  if (data.segment[trackpts]['name'] === undefined) nam= 'TrackPts-' + trackpts; 
                      else nam=data.segment[trackpts]['name'];
                  
                  lat=parseFloat (data.segment[trackpts]["$"].lat);
                  lon=parseFloat (data.segment[trackpts]["$"].lon);
                  spd=data.segment[trackpts]['sog'];
                  crs=data.segment[trackpts]['course'];
                  alt=data.segment[trackpts]['ele'];
                  dat=data.segment[trackpts]['time'];
                  //console.log ("name=%s  lat=%s lon=%s sog=%s course=%s alt=%s", nam, lat, lon, spd, crs, alt);
                  route.waypts.push ({name: nam, lat: lat, lon: lon, date: dat});
                  route.count++;
              }
              break;
          case 'route':
              var nam, lat, lon;
              for (var routepts in data.segment)  {
                  // console.log ("routepts[%s]=%s", routepts, JSON.stringify(data.segment[routepts]));
                  if (data.segment[routepts]['name'] === undefined)
                      nam= 'TrackPts-' + routepts;
                  else
                      nam=data.segment[routepts]['name'];
  
                  lat=parseFloat (data.segment[routepts]["$"].lat);
                  lon=parseFloat (data.segment[routepts]["$"].lon);
                  // console.log ("name=%s  lat=%s lon=%s", nam, lat, lon);
                  route.waypts.push ({name: nam, lat: lat, lon: lon});
                  route.count++;
              }
              break;
          }
      }