tkrajina/gpxpy

gpx-file "not well-formed"

Closed this issue · 2 comments

Hi, I've written a little script to extract the heartrate, cadence, speed and other values from a gpx-track-file. The information is mostly stored in gpx-extensions.
The script works fine with a number of gpx-files but does not accept the original Garmin gpx-files:
This is the error:

File "C:\Program Files\ArcGis_Pro\bin\Python\envs\arcgispro-py3\lib\xml\etree\ElementTree.py", line 1314, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 1

The error does not occure, when I delete all the Lines with extensions in the gpx-file.
My idea is, that the error comes because of the use of a wrong namespace:
When printing the speed-tag I get:

{http://www.gps-freeware.de/xmlschema/TrackPointExtension/v1}speed

The namespace of a garmin file should be: "http://www.topografix.com/GPX/1/1"
So, how can I change the namespace?
If needed, I will provide any information you want... ;-)
I've read the "Extension data for Garmin gpx files"-Issue but I think, this is an other, not related problem.
Thank you very much in advance,
best regards, Andreas

Nobody out there, who knows how to define a namespace in GPXPY??

A few notes about your issue:

  • It's not really an "issue", it's a question ("how can I change the namespace?").
  • StackOverflow is probably a better place to ask questions.
  • This project is open source so that you can search the source code.
  • I don't know the answer from memory, but it took me cca 30s to find that GPX has a dict with all the namespaces (https://github.com/tkrajina/gpxpy/blob/master/gpxpy/gpx.py#L2704). I'm not sure if that will solve your problem, but at least it's an answer to your question.