1

I get this error when parsing a GPX file like so:

gpx_file_object = open(path_and_file, 'r')
parser = gpxpy.parse(gpx_file_object)

The GPX file looks like so:

<?xml version='1.0' encoding='UTF-8'?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://www.topografix.com/GPX/1/1" creator="EMNRD.GPXWriter" 
     version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 
     http://www.topografix.com/GPX/1/1/gpx.xsd">
  <time>01/07/2016  07:49:50</time>
  <metadata>
    <name>0/0</name>
    <desc>24989196</desc>
  </metadata>
  <trk>
    <name>0/0</name>
    <trkseg>
      <trkpt lat="35.000096" lon="-108.050042"/>
      <trkpt lat="34.5277756667" lon="-108.050042"/>
      <trkpt lat="34.5277756667" lon="-107.4452589"/>
      <trkpt lat="35.000096" lon="-107.4452589"/>
      <trkpt lat="34.000096" lon="-108.050042"/>
    </trkseg>
  </trk>
</gpx>

This GPX file was generated by python code I wrote using lxml/etree. I looked at the file in an editor, both in text and hex mode, and don't see anything unusual. I pasted the above into an xml validator and it passed. I loaded the GPX file into MOBAC and it looks good.

I've read this question and found no solution there for me:

Any suggestions?

Community
  • 1
  • 1
Al Lelopath
  • 6,448
  • 13
  • 82
  • 139

1 Answers1

2

The GPX file in your question is well-formed, so either it's not really what the parser is seeing or the error message is wrong.

You alone can confirm what the parser is really seeing. Proceeding with the (unlikely) possibility that the error message is wrong, you do still have validation issues to deal address. (In XML, valid is not the same as well-formed.)

Here is your GPX file, which was already well-formed, despite the error message, corrected to be valid too:

<?xml version='1.0' encoding='UTF-8'?>
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://www.topografix.com/GPX/1/1"
     creator="EMNRD.GPXWriter"
     version="1.1"
     xsi:schemaLocation="http://www.topografix.com/GPX/1/1 gpx.xsd">
  <metadata>
    <name>0/0</name>
    <desc>24989196</desc>
    <time>2016-01-07T00:00:00</time>
  </metadata>
  <trk>
    <name>0/0</name>
    <trkseg>
      <trkpt lat="35.000096" lon="-108.050042"/>
      <trkpt lat="34.5277756667" lon="-108.050042"/>
      <trkpt lat="34.5277756667" lon="-107.4452589"/>
      <trkpt lat="35.000096" lon="-107.4452589"/>
      <trkpt lat="34.000096" lon="-108.050042"/>
    </trkseg>
  </trk>
</gpx>

Note that time was misplaced and of incorrect form prior to the above fix.

Community
  • 1
  • 1
kjhughes
  • 106,133
  • 27
  • 181
  • 240