title: using rest and parsing xml in python
body: <p>I have a python script that does a REST GET call and stores the xml response in a string "response". However when I try to print the root of the XML, it fails with the following error.  If i just print response i.e "print response.read()", I get the response body correctly. What could be wrong here? Could you please help?</p>
  
  <pre><code>import urllib
  import urllib2
  import xml.etree.ElementTree as ET
  
  url = "http://192.168.1.1/health"
  headers = {"Content-Type":"application/xml"}
  
  request = urllib2.Request(url)
  
  for key in headers.items():
    request.add_header(key)
  
  response = urllib2.urlopen(request)
  
  #print response.read()
  
  root = ET.fromstring(response)
  
  #print root
  </code></pre>
  
  <p>Here is the error when executing the script</p>
  
  <pre><code>~]# python test4.py
  Traceback (most recent call last):
    File "test4.py", line 24, in &lt;module&gt;
      root = ET.fromstring(response)
    File "/usr/lib64/python2.6/xml/etree/ElementTree.py", line 963, in XML
      parser.feed(text)
    File "/usr/lib64/python2.6/xml/etree/ElementTree.py", line 1245, in feed
      self._parser.Parse(data, 0)
  TypeError: Parse() argument 1 must be string or read-only buffer, not instance
  </code></pre>