tkrajina / gpxpy

gpx-py is a python GPX parser. GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
Apache License 2.0
993 stars 223 forks source link

"Error parsing XML: not well-formed (invalid token): line 1, column 1" #193

Closed Shohreh closed 4 years ago

Shohreh commented 4 years ago

Hello,

Using Python 3.7.0 on Windows, gpxpy — both 0.9.8 and 1.4.0 — fails reading this GPX file using the following code:

import gpxpy
import gpxpy.gpx

f = open('Piste_01.gpx', 'r')
#gpxpy.gpx.GPXXMLSyntaxException: Error parsing XML: not well-formed (invalid token): line 1, column 1
gpx = gpxpy.parse(f)

Any idea what it could be?

I'm trying to read all [trk] found in multiple GPX files, and merge them into a single GPX file.

Thank you.

Shohreh commented 4 years ago

Found it: It contained the BOM at the top, which isn't displayed unless opening the file in hex mode.

Removing the BOM solved the issue.

https://simple.wikipedia.org/wiki/Byte_order_mark

HTH,