def gpx(self,gpx): "Construct an ElementTree for the given GPX file" root = Element("gpx",xmlns=NS,version="1.1",creator=self.creator) for wpt in gpx.waypoints: root.append(self.wpt(wpt,"wpt")) for route in gpx.routes: el = self.path(route,"rte","rtept") xmlutil.write(el,route,Route._scheme) root.append(el) for track in gpx.tracks: el = SubElement(root,"trk") xmlutil.write(el,track,Track._scheme) for seg in track: el.append(self.path(seg,"trkseg","trkpt")) return root
def wpt(self,wpt,name): "Creates an XML element with specified name which represents this Waypoint" e = Element(name) xmlutil.write(e,wpt,Waypoint._scheme) return e