Next / Previous / Contents / Shipman's homepage

16.3. Photo.writeNode()

birdnotes.py
# - - -   P h o t o . w r i t e N o d e

    def writeNode ( self, parent ):
        """Convert to XML.
        """
        #-- 1 --
        # [ parent  :=  parent with a new rnc.PHOTO_N child
        #   photoNode  :=  that new child ]
        photoNode  =  et.SubElement ( parent, rnc.PHOTO_N )

        #-- 2 --
        # [ photoNode  :=  photoNode with self.catNo added as
        #       an rnc.CAT_NO_A attribute and self.text added
        #       as content (which may be None) ]
        photoNode.attrib [ rnc.CAT_NO_A ]  =  self.catNo
        photoNode.text  =  self.text

        #-- 3 --
        if  self.url:
            photoNode.attrib [ rnc.URL_A ]  =  self.url