[XML-SIG] element-value in multiple namespace

Mark Tolonen metolone+gmane at gmail.com
Mon Dec 1 00:41:41 CET 2008

"Christian Benke" <benkokakao at gmail.com> wrote in message 
news:20081130202537.c56fec35.benkokakao at gmail.com...
> 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:


or more precisely:


Aren't namespaces fun?


More information about the XML-SIG mailing list