def replace(text):
  """Replace both the hex and decimal versions of symbols in an XML string"""
  for hex, value in UNICODE_DICTIONARY.items():
    num = int(hex[3:-1], 16)
    #uni = unichr(num)
    decimal = '&#' + str(num) + ';'
    for key in [ hex, decimal ]: #uni
      text = text.replace(key, value)
  return text
Replace both the hex and decimal versions of symbols in an XML string