code: def Write(self, schedule, output_file):
      
      # Generate the DOM to write
      root = ET.Element('kml')
      root.attrib['xmlns'] = 'http://earth.google.com/kml/2.1'
      doc = ET.SubElement(root, 'Document')
      open_tag = ET.SubElement(doc, 'open')
      open_tag.text = '1'
      self._CreateStopsFolder(schedule, doc)
      if self.split_routes:
        route_types = set()
        for route in schedule.GetRouteList():
          route_types.add(route.route_type)
        route_types = list(route_types)
        route_types.sort()
        for route_type in route_types:
          self._CreateRoutesFolder(schedule, doc, route_type)
      else:
        self._CreateRoutesFolder(schedule, doc)
      self._CreateShapesFolder(schedule, doc)
  
      # Make sure we pretty-print
      self._SetIndentation(root)
  
      # Now write the output
      if isinstance(output_file, file):
        output = output_file
      else:
        output = open(output_file, 'w')
      output.write("""<?xml version="1.0" encoding="UTF-8"?>\n""")
      ET.ElementTree(root).write(output, 'utf-8')
docs: Writes out a feed as KML.
  
      Args:
        schedule: A transitfeed.Schedule object containing the feed to write.
        output_file: The name of the output KML file, or file object to use.