tkrajina/gpxpy

Extracting namespace element / attribute values

lakeuk opened this issue · 1 comments

How do I extract element / attribute values contained under the groundspeak namespace, below sample gpx and my basic code so far using examples. I've see examples using extensions but these have a extension element included which my gpx doesn't hold.

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <gpx version="1.0" creator="c:geo - http://www.cgeo.org/" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0/1 http://www.groundspeak.com/cache/1/0/1/cache.xsd http://www.gsak.net/xmlv1/6 http://www.gsak.net/xmlv1/6/gsak.xsd" xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0/1" xmlns:gsak="http://www.gsak.net/xmlv1/6" xmlns:cgeo="http://www.cgeo.org/wptext/1/0"> <wpt lat="54.00000" lon="-2.000000"> <time>2013-05-29T00:00:00Z</time> <name>GC00000</name> <desc>Cache Name</desc> <url>https://coord.info/GC00000</url> <urlname>Cache Name</urlname> <sym>Geocache</sym> <type>Geocache|Traditional Cache</type> <groundspeak:cache id="0000000" available="True" archived="False"> <groundspeak:name>cache name</groundspeak:name> <groundspeak:placed_by>me</groundspeak:placed_by> <groundspeak:owner>cache owner</groundspeak:owner> <groundspeak:type>Traditional Cache</groundspeak:type> <groundspeak:container>Micro</groundspeak:container> </groundspeak:cache> </wpt> </gpx>

`import gpxpy

gpx_file = open('sample.xml', 'r', encoding='utf8')
gpx = gpxpy.parse(gpx_file)

for wpt in gpx.waypoints:
print(wpt.name)`

Hi @lakeuk

As you already said -- this is not an extension. Gpxpy can't handle it.