title: Parsing soap/XML response in Python
body: <p>I am trying to parse the below xml using the python. I do not understand which type of xml this is as I never worked on this kind of xml.I just got it from a api response form Microsoft.</p>
  
  <p>Now my question is how to parse and get the value of <code>BinarySecurityToken</code> in my python code.</p>
  
  <p>I refer this question <a href="https://stackoverflow.com/questions/14828379/parse-xml-soap-response-with-python">Parse XML SOAP response with Python</a> </p>
  
  <p>But look like this has also some xmlns to get the text .However in my xml I can't see any nearby xmlns value through I can get the value.</p>
  
  <p>Please let me know how to get the value of a specific filed using python from below xml.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;
    &lt;S:Header&gt;
      &lt;wsa:Action xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Action" S:mustUnderstand="1"&gt;http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue&lt;/wsa:Action&gt;
      &lt;wsa:To xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="To" S:mustUnderstand="1"&gt;http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous&lt;/wsa:To&gt;
      &lt;wsse:Security S:mustUnderstand="1"&gt;
        &lt;wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="TS"&gt;
          &lt;wsu:Created&gt;2017-06-12T10:23:01Z&lt;/wsu:Created&gt;
          &lt;wsu:Expires&gt;2017-06-12T10:28:01Z&lt;/wsu:Expires&gt;
        &lt;/wsu:Timestamp&gt;
      &lt;/wsse:Security&gt;
    &lt;/S:Header&gt;
    &lt;S:Body&gt;
      &lt;wst:RequestSecurityTokenResponse xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault"&gt;
        &lt;wst:TokenType&gt;urn:passport:compact&lt;/wst:TokenType&gt;
        &lt;wsp:AppliesTo xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;
          &lt;wsa:EndpointReference&gt;
            &lt;wsa:Address&gt;https://something.something.something.com&lt;/wsa:Address&gt;
          &lt;/wsa:EndpointReference&gt;
        &lt;/wsp:AppliesTo&gt;
        &lt;wst:Lifetime&gt;
          &lt;wsu:Created&gt;2017-06-12T10:23:01Z&lt;/wsu:Created&gt;
          &lt;wsu:Expires&gt;2017-06-13T10:23:01Z&lt;/wsu:Expires&gt;
        &lt;/wst:Lifetime&gt;
        &lt;wst:RequestedSecurityToken&gt;
          &lt;wsse:BinarySecurityToken Id="Compact0"&gt;my token&lt;/wsse:BinarySecurityToken&gt;
        &lt;/wst:RequestedSecurityToken&gt;
        &lt;wst:RequestedAttachedReference&gt;
          &lt;wsse:SecurityTokenReference&gt;
            &lt;wsse:Reference URI="wwwww="&gt;
            &lt;/wsse:Reference&gt;
          &lt;/wsse:SecurityTokenReference&gt;
        &lt;/wst:RequestedAttachedReference&gt;
        &lt;wst:RequestedUnattachedReference&gt;
          &lt;wsse:SecurityTokenReference&gt;
            &lt;wsse:Reference URI="swsw="&gt;
            &lt;/wsse:Reference&gt;
          &lt;/wsse:SecurityTokenReference&gt;
        &lt;/wst:RequestedUnattachedReference&gt;
      &lt;/wst:RequestSecurityTokenResponse&gt;
    &lt;/S:Body&gt;
  &lt;/S:Envelope&gt;
  </code></pre>