"Christian Benke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hello!
I'm currently struggling to extract some information from a gpx-file
(geodata in xml-format). You can see the xml-content here:
http://benko.login.cx/2008-11-21.xml
So far i've managed to get out most of the values with this function:
tree = etree.parse(gpxfile)
gpx_namespace = "http://www.topografix.com/GPX/1/1"
root = tree.getroot()
trackSegments = root.getiterator("{%s}trkseg"%gpx_namespace)
for trackSegment in trackSegments:
for trackPoint in trackSegment:
lat=trackPoint.attrib['lat']
lon=trackPoint.attrib['lon']
altitude=trackPoint.find('{%s}ele'% gpx_namespace).text
time=trackPoint.find('{%s}time'% gpx_namespace).text
However, i have little idea what the syntax to pick out the
values of the Temperature- and Pressure-elements has to be, which have
an additional namespace, plus they
have a "gpxx:"-prefix. I've struggled yesterday night with
this but didn't succeed. Can someone give me a kick-off how this would
work?
This works with some assumptions:
pressure=trackPoint.find('*/*/{http://gps.wintec.tw/xsd/}Pressure').text
temp=trackPoint.find('*/*/{http://gps.wintec.tw/xsd/}Temperature').text
or more precisely:
pressure=trackPoint.find('{http://www.topografix.com/GPX/1/1}extensions/{http://gps.wintec.tw/xsd/}TrackPointExtension/{http://gps.wintec.tw/xsd/}Pressure').text
temp=trackPoint.find(''{http://www.topografix.com/GPX/1/1}extensions/{http://gps.wintec.tw/xsd/}TrackPointExtension/{http://gps.wintec.tw/xsd/}Temperature').text
Aren't namespaces fun?
-Mark
_______________________________________________
XML-SIG maillist - XML-SIG@python.org
http://mail.python.org/mailman/listinfo/xml-sig