Click to See Complete Forum and Search --> : search for the value of an attribute and remove markups


freebourg
08-31-2008, 04:53 PM
First, excuse me for my so bad english.

I travelled a bit and collected some gps log data into gpx format (which is XML). See this : http://www.topografix.com/gpx.asp

I used gpxlogger in order to do the work (read the output of gpsd and write it in the gpx file).

Here's a normal log :

<gpx>
<trk>
<trkseg>
<trkpt lat="46.755572" lon="7.152242">
<ele>nan</ele>
<time>2008-08-30T12:37:02Z</time>
<fix>2d</fix>
</trkpt>
<trkpt lat="46.755572" lon="7.152242">
<ele>724.600000</ele>
<time>2008-08-30T12:37:03Z</time>
<fix>3d</fix>
</trkpt>
</trkseg>
</trk>
</gpx>


Sometimes (half the time in fact...), gpxlogger write this :
<trk>
<trkseg>
<trkpt lat="nan" lon="nan">
<ele>nan</ele>
<time>1901-12-13T20:45:52Z</time>
<fix>3d</fix>
</trkpt>
</trkseg>
</trk>


The problem is that some software (for example bikeXperience & Google Maps) don't like these.

Can somebody help me :

- Tell gpxlogger to shut up when this case happens, would be the simpliest solution
- It may exist some filter for gpsbabel to remove these bad tracks
- Write a script that remove this and print a correct gpx file
- A good solution must be to write "Regular expressions" to do this, but I failed. Does someone know which string work in this case ?

Thanks in advance,

Mathieu.

Alain COUTHURES
09-06-2008, 02:46 PM
Instead of a regular expression, it would be easier to use the DOM API for removing those invalid elements which, apparently, can be selected by an XPath expression.

XSLT might also be use but it might be less efficient...