On Sun, 30 Nov 2008 21:24:53 +0100 Stefan Behnel <[EMAIL PROTECTED]> 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \n<gpxx:TrackPointExtension xmlns:gpxx="http://gps.wintec.tw/xsd/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://gps.wintec.tw/xsd http://gps.wintec.tw/xsd/TMX_GpxExt.xsd"> \n<gpxx:Temperature>26</gpxx:Temperature> \n<gpxx:Pressure>1020</gpxx:Pressure>\n</gpxx:TrackPointExtension> \n</extensions>\n' 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? Puzzled Christian _______________________________________________ XML-SIG maillist - XML-SIG@python.org http://mail.python.org/mailman/listinfo/xml-sig