code: def xmlobject_to_dict(instance, fields=None, exclude=None, prefix=''):
      
      data = {}
      # convert prefix to combining form for convenience
      if prefix:
          prefix = '%s-' % prefix
      else:
          prefix = ''
  
      for name, field in six.iteritems(instance._fields):
          # not editable?
          if fields and not name in fields:
              continue
          if exclude and name in exclude:
              continue
          if isinstance(field, xmlmap.fields.NodeField):
              nodefield = getattr(instance, name)
              if nodefield is not None:
                  subprefix = '%s%s' % (prefix, name)
                  node_data = xmlobject_to_dict(nodefield, prefix=subprefix)
                  data.update(node_data)   # FIXME: fields/exclude
          if isinstance(field, xmlmap.fields.NodeListField):
              for i, child in enumerate(getattr(instance, name)):
                  subprefix = '%s%s-%d' % (prefix, name, i)
                  node_data = xmlobject_to_dict(child, prefix=subprefix)
                  data.update(node_data)   # FIXME: fields/exclude
          else:
              data[prefix + name] = getattr(instance, name)
  
      return data
docs: Generate a dictionary based on the data in an XmlObject instance to pass as
      a Form's ``initial`` keyword argument.
  
      :param instance: instance of :class:`~eulxml.xmlmap.XmlObject`
      :param fields: optional list of fields - if specified, only the named fields
              will be included in the data returned
      :param exclude: optional list of fields to exclude from the data