I am trying to iterate through XML from a Requests response. Right now my python code look as such:
data = requests.post(url, data=xml, headers=headers).content
tree = ElementTree.fromstring(data)
And my XML looks as such:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetPasswordResponse xmlns="https://tempuri.org/">
<GetPasswordResult>
<Content>ThisisContent</Content>
<UserName>ExampleName</UserName>
<Address>ExServer</Address>
<Database>tempdb</Database>
<PolicyID>ExPolicy</PolicyID>
<Properties>
<KeyAndValue>
<key>Content</key>
<value>ThisisContent</value>
</KeyAndValue>
<KeyAndValue>
<key>ReconcileIsWinAccount</key>
<value>Yes</value>
</KeyAndValue>
</Properties>
</GetPasswordResult>
</GetPasswordResponse>
</soap:Body></soap:Envelope>'
How would I go about pulling out the values for the <Content>, <UserName>, and <PolicyID> tags using ElementTree? I have tried many different things but can't seem to get any of the values accessible.