[XML-SIG] element-value in multiple namespace

Christian Benke benkokakao at gmail.com
Sun Nov 30 22:22:57 CET 2008

On Sun, 30 Nov 2008 21:24:53 +0100
Stefan Behnel <stefan_ml at behnel.de> wrote:

> > 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

> Then use that namespace to ask for them in exactly the same way as
> you did above with the gpx_namespace.
> http://effbot.org/zone/element-namespaces.htm
> http://effbot.org/zone/element-xpath.htm

I'm afraid thats what i'm trying all the time. Using the script above
gives me a trackPoint-element - Running

>>> etree.tostring(trackPoint.find('{%s}extensions'% gpx_namespace))
'<extensions xmlns="http://www.topografix.com/GPX/1/1"
\n<gpxx:TrackPointExtension xmlns:gpxx="http://gps.wintec.tw/xsd/"

which is the subtree i'm looking for.

I'd assume i can
grab the contents of this with:

  ext_namespace = "http://gps.wintec.tw/xsd"
  trackPoint.find('{%s}extensions'% gpx_namespace)).find('{%s}
Temperature'% ext_namespace)

But this is not correct, the result is 'None'.
Imho this is exactly the same as further above where i extract
lon,lat,altitude,..., besides that i don't use gpx_namespace but
ext_namespace in the find().

Should the gpx_namespace be applied additionally to the ext_namespace in
the extensions-subelements as it is a subelement of the gpx_namespace?


More information about the XML-SIG mailing list