Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing tag(s) during parsing #135

Closed
tudorp opened this issue Aug 20, 2018 · 3 comments
Closed

Missing tag(s) during parsing #135

tudorp opened this issue Aug 20, 2018 · 3 comments
Labels

Comments

@tudorp
Copy link

tudorp commented Aug 20, 2018

Tried to parse a file with Python 3 looking as follows:
<?xml version='1.0' encoding='UTF-8'?> <gpx version='1.1' creator='GPSMID' xmlns='http://www.topografix.com/GPX/1/1'> <trk> <trkseg> <trkpt lat='40.61262' lon='10.592117'> <ele>100</ele> <time>2018-01-01T09:00:00Z</time> </trkpt> </trk> </gpx>

I noticed that the trk tags were missed due to the fact that the parsed node tag name looked like:
'{http://www.topografix.com/GPX/1/1}trk', which did not match trk

My workaround was to replace the original tag matching in method from_xml from class GPXField in file gpxfield.py:
if child.tag == self.tag:
with a regular expression that would match the tags while ignoring any prefix bound in curly brackets:
if re.match('^({[^{]*})?' + self.tag + '$', child.tag) is not None:

To be honest, I did not have the time to dig out why that prefix appeared on the tag...

@tudorp
Copy link
Author

tudorp commented Aug 20, 2018

Similar issue found for the elevation tag parsing in class GPXComplexField from same file. I implemented a similar workaround that solves the problem in my project

@tkrajina
Copy link
Owner

tkrajina commented Aug 20, 2018

I just wrote a test in (eaef6a7) and there is definitely something weird happening here. Another strange thing is that if you change single to double quotes in xmlns.

<gpx version='1.1' creator='GPSMID' xmlns='http://www.topografix.com/GPX/1/1'>

to

<gpx version='1.1' creator='GPSMID' xmlns="http://www.topografix.com/GPX/1/1">

The test passes.

@tkrajina tkrajina added the bug label Aug 21, 2018
@tkrajina
Copy link
Owner

tkrajina commented Sep 16, 2018

Fixed in dev, will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants