Next / Previous / Contents / Shipman's homepage

11.3. Gps.writeNode(): Convert to XML

This method converts a Gps instance into a gps XML element. The waypoint attribute is required. Text will be added to the element only if it is not None in the instance.

birdnotes.py
# - - -   G p s . w r i t e N o d e

    def writeNode(self, parent):
        """Convert to XML
        """
        #-- 1 --
        # [ parent  :=  parent with a new rnc.GPS_N child added
        #       with rnc.WAYPOINT_A attribute set to self.waypoint ]
        gpsNode = et.SubElement(parent, rnc.GPS_N)
        gpsNode.attrib[rnc.WAYPOINT_A] = self.waypoint

        #-- 2 --
        # [ if self.text is not None ->
        #     gpsNode  :=  gpsNode with its content set to self.text
        #   else -> I ]
        if  self.text is not None:
            gpsNode.text = self.text

        #-- 3 --
        return gpsNode