code: def writeGenerator(self, gen):
          
          n = getattr(gen, 'next')
  
          while True:
              try:
                  self.writeElement(n())
              except StopIteration:
                  break
docs: Iterates over a generator object and encodes all that is returned.