title: Python encoding problems in xml
body: <p>I have a media player that I would like to send what I'm playing to trakt.tv, everything works fine except for foreign letters in the title/path. The system is running python 2.7.3</p>
  
  <pre><code>def getStatus(self,ip,timeout=10.0):
      oPchStatus = PchStatus()
      try:
          oResponse = urlopen("http://" + ip + ":8008/playback?arg0=get_current_vod_info",None,timeout)
          oPchStatus = self.parseResponse(oResponse.readlines()[0])
      return oPchStatus
  </code></pre>
  
  <p>This will return some thing like this.</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;theDavidBox&gt;
    &lt;request&gt;
      &lt;arg0&gt;get_current_vod_info&lt;/arg0&gt;
      &lt;module&gt;playback&lt;/module&gt;
    &lt;/request&gt;
    &lt;response&gt;
      &lt;currentStatus&gt;pause&lt;/currentStatus&gt;
      &lt;currentTime&gt;3190&lt;/currentTime&gt;
      &lt;downloadSpeed&gt;0&lt;/downloadSpeed&gt;
      &lt;fullPath&gt;/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/FILMS/A.Haunted.House.(2013)/A Haunted House.avi&lt;/fullPath&gt;
      &lt;lastPacketTime&gt;0&lt;/lastPacketTime&gt;
      &lt;mediatype&gt;OTHERS&lt;/mediatype&gt;
      &lt;seekEnable&gt;true&lt;/seekEnable&gt;
      &lt;title/&gt;
      &lt;totalTime&gt;4860&lt;/totalTime&gt;
    &lt;/response&gt;
    &lt;returnValue&gt;0&lt;/returnValue&gt;
  &lt;/theDavidBox&gt;
  </code></pre>
  
  <p>The next step takes the above and assigns each item to a variable.</p>
  
  <pre><code>class PchStatus:
      def __init__(self):
          self.status=EnumStatus.NOPLAY
          self.fullPath = u""
          self.fileName = u""
          self.currentTime = 0
          self.totalTime = 0
          self.percent = 0
          self.mediaType = ""
          self.currentChapter = 0 # For Blu-ray Disc only
          self.totalChapter = 0 # For Blu-ray Disc only
          self.error = None
  
  class PchRequestor:
  
      def parseResponse(self, response):
          oPchStatus = PchStatus()
          try:
              response = unescape(response)
              oXml = ElementTree.XML(response)
              if oXml.tag == "theDavidBox": # theDavidBox should be the root
                  if oXml.find("returnValue").text == '0' and int(oXml.find("response/totalTime").text) &gt; 90:#Added total time check to avoid scrobble while playing adverts/trailers
                      oPchStatus.totalTime = int(oXml.find("response/totalTime").text)
                      oPchStatus.status = oXml.find("response/currentStatus").text
                      oPchStatus.fullPath = oXml.find("response/fullPath").text
                      oPchStatus.currentTime = int(oXml.find("response/currentTime").text)
  </code></pre>
  
  <p>and so on. Using the above returned xml,</p>
  
  <p>oPchStatus.totalTime would be "4860"
  oPchStatus.status would be "pause"
  oPchStatus.fullPath would be "/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/FILMS/A.Haunted.House.(2013)/A Haunted House.avi"
  oPchStatus.currentTime would be "3190"</p>
  
  <p>This, like I said this works well until a foreign letter is in the title. A title like Le.Fabuleux.Destin.d'Amélie.Poulain.(2001).avi will make oPchStatus.fullPath contain the string "/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/Le.Fabuleux.Destin.d&apos;Am\xe9lie.Poulain.(2001).avi"</p>
  
  <p>and not</p>
  
  <p>"/opt/sybhttpd/localhost.drives/HARD_DISK/Storage/NAS/Videos/Le.Fabuleux.Destin.d'Amélie.Poulain.(2001).avi"</p>
  
  <p>as i want it to be.</p>
  
  <p>Further on in the script there are routines to scan xml files for the file name and also to create FILENAME.watched so i need to file names to match the actual file name and not replace any letters.</p>
  
  <p>What would be the best way to ensure these types of file names are encoded properly? 
  I have tried to provide as much info as possable but if you need more info please just ask.</p>