title: Trouble creating HttpResponse for xml download, Django
body: <p>I'm trying to let the user download an xml file that i have generated.</p>
  
  <p>This is my code: </p>
  
  <pre><code>tree.write('output.xml', encoding="utf-16")
  # Pathout is the path to the output.xml
  xmlFile = open(pathout, 'r')
  myfile = FileWrapper(xmlFile.read())
  response = HttpResponse(myfile, content_type='application/xml')
  response['Content-Disposition'] = 'attachment; filename='+filename
  return response
  </code></pre>
  
  <p>When I try to create my response I get this exception:</p>
  
  <pre><code>'\\'str\\' object has no attribute \\'read\\''
  </code></pre>
  
  <p>Can't figure out what I'm doing wrong. Any ideas?</p>
  
  <p>Edit:
  When I use this code I get no errors but instead the downloaded file is empty</p>
  
  <pre><code>tree.write('output.xml', encoding="utf-16")
  xmlFile = open(pathout, 'r')
  myfile = FileWrapper(xmlFile)
  
  response = HttpResponse(myfile, content_type='application/xml')
  response['Content-Disposition'] = 'attachment; filename='+filename
  return response
  </code></pre>