title: AttributeError: 'list' object has no attribute 'iter'
body: <p>This code generates the following error "AttributeError: 'list' object has no attribute 'iter'" when returning a list via <code>et.tostring()</code>. I imported <code>xml.etree.ElementTree</code> as <code>et</code></p>
  
  <p>I've tried using <code>et.tostringlist()</code>, and can't find a solution to my problem elsewhere. </p>
  
  <pre><code>import xml.etree.ElementTree as et
  class SerializerFactory:
  
      def serialize_all(self, format, member_list):
          if format == 'JSON':
              serialize = JsonSerializer(member_list)
              serialize.start_all_objects()
              return serialize
          elif format == 'XML':
              serialize = XmlSerializer(member_list)
              serialize.start_all_objects()
              return serialize
          else:
              raise ValueError("Format must be 'JSON' or 'XML'.")
  
      def serialize_one(self, format, index, member_list):
          if format == 'JSON':
              return JsonSerializer(member_list).start_one_object(index)
          elif format == 'XML':
              return XmlSerializer(member_list).start_one_object(index)
          else:
              raise ValueError("Format must be 'JSON' or 'XML'.")
  
  
  class XmlSerializer:
      def __init__(self, member_list):
          self.member_list = member_list
          self.serialize_list = [] * member_list.size
  
      def start_all_objects(self):
          for i in range(self.member_list.size):
              member = self.member_list[i]
              number = member.mem_num
              l_name = member.l_name
              f_name = member.f_name
              mem_type = member.mem_type
              mem_list = et.Element({'Number': number, 'Last Name': l_name,
                                     'First Name': f_name, 'Membership Type': mem_type})
  
              self.serialize_list.append(mem_list)
  
      def start_one_object(self, index):
          member = self.member_list[index]
          number = member.mem_num
          l_name = member.l_name
          f_name = member.f_name
          mem_type = member.mem_type
          mem_list = et.Element({'Number': number, 'Last Name': l_name,
                                 'First Name': f_name, 'Membership Type': mem_type})
          self.serialize_list.append(mem_list)
  
      def to_str(self):
          return et.tostring(self.serialize_list, encoding='unicode')
  
  
  factory = MemberSerializer.SerializerFactory()
  xml = factory.serialize_all('XML', mem_list)
  print(xml.to_str())
  </code></pre>
  
  <p>I wanted to return an entire list in xml, not sure if this actually possible, but it seemed reasonable. Here is the error message I received</p>
  
  <pre><code>Traceback (most recent call last):
      File "C:/Users/Nate Dawg/PycharmProjects/Membership/Test.py", line 36, in &lt;module&gt;
      print(xml.to_str())
  File "C:\Users\Nate Dawg\PycharmProjects\Membership\MemberSerializer.py", line 89, in to_str
      return et.tostring(self.serialize_list, encoding='unicode')
  File "C:\Users\Nate Dawg\AppData\Local\Programs\Python\Python36-32\lib\xml\etree\ElementTree.py", line 1135, in tostring
      short_empty_elements=short_empty_elements)
  File "C:\Users\Nate Dawg\AppData\Local\Programs\Python\Python36-32\lib\xml\etree\ElementTree.py", line 773, in write
      qnames, namespaces = _namespaces(self._root, default_namespace)
  File "C:\Users\Nate Dawg\AppData\Local\Programs\Python\Python36-32\lib\xml\etree\ElementTree.py", line 876, in _namespaces
      for elem in elem.iter():
  AttributeError: 'list' object has no attribute 'iter'
  </code></pre>