title: How to parse XML coming from a URL in a byte string format using Python
body: <p>I have data coming as xml in a byte string from a URL as shown below. I try to parse this data and read certain elements like the value of  name=&quot;profile&quot; = AI. I was able to get the data and convert the byte to string but all attempts to print name=&quot;profile&quot; value AI failed.</p>
  <hr />
  <pre><code>&lt;msgresponse&gt;
      &lt;field name=&quot;errorCode&quot; value=&quot;0&quot;/&gt;
      &lt;field name=&quot;errorMsg&quot; value=&quot;:SUCCESSFUL&quot;/&gt;
      &lt;field name=&quot;profile&quot; value=&quot;AI&quot;/&gt;
      &lt;field name=&quot;statsDescptn&quot; value=&quot;:SUCCESSFUL&quot;/&gt;
      &lt;field name=&quot;SWNM&quot; value=&quot;212196905&quot;/&gt;
  &lt;/msgresponse&gt;
  </code></pre>
  <hr />
  <hr />
  <pre><code>from urllib.request import urlopen
  import xml.etree.ElementTree as ET
  from xml.etree.ElementTree import XML, fromstring
  url = 'https://'
  my_var = urlopen(url)
  for i in my_var:
      name_str = i.decode()
      print(type(name_str))
      root = ET.fromstring(name_str)
      for x in root:
          print(x)
  </code></pre>
  <hr />