def xml_dict(data):
 xml = ''
 ordered_items = OrderedDict(sorted(data.items()))
 for (k, v) in ordered_items.items():
  if isinstance(v, datetime.datetime):
   v = date_to_str(v)
  elif isinstance(v, (datetime.time, datetime.date)):
   v = v.isoformat()
  if (not isinstance(v, list)):
   v = [v]
  for value in v:
   if isinstance(value, dict):
    links = xml_add_links(value)
    xml += ('<%s>' % k)
    xml += xml_dict(value)
    xml += links
    xml += ('</%s>' % k)
   else:
    xml += ('<%s>%s</%s>' % (k, utils.escape(value), k))
 return xml

def xml_dict ( data ) : xml = '' ordered_items = OrderedDict ( sorted ( data . items ( ) ) ) for ( k , v ) in ordered_items . items ( ) : if isinstance ( v , datetime . datetime ) : v = date_to_str ( v ) elif isinstance ( v , ( datetime . time , datetime . date ) ) : v = v . isoformat ( ) if ( not isinstance ( v , list ) ) : v = [ v ] for value in v : if isinstance ( value , dict ) : links = xml_add_links ( value ) xml += ( '<%s>' % k ) xml += xml_dict ( value ) xml += links xml += ( '</%s>' % k ) else : xml += ( '<%s>%s</%s>' % ( k , utils . escape ( value ) , k ) ) return xml
renders a dict as xml .