I have this service that I am calling and it returns to me data in xml format. I want to extract the server address from that. How can I do that? This is what I get when I call from the service.
from xml.dom import minidom
import requests
url="http://172.10.3.2:51106/GetConnectionStrings.asmx"
#headers = {'content-type': 'application/soap+xml'}
headers = {'content-type': 'text/xml'}
body = """<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<DatabaseConnectionString xmlns='http://tempuri.org/'>
<DatabaseName>ELMA</DatabaseName>
<ApplicationName>MonitoringSystem</ApplicationName>
</DatabaseConnectionString>
</soap:Body>
</soap:Envelope>"""
response = requests.post(url,data=body,headers=headers)
#print response.content
doc = minidom.parseString(response.content)
# doc.getElementsByTagName returns NodeList
name = doc.getElementsByTagName("DatabaseConnectionStringResult")[0]
print(name.firstChild.data)
This is what I tried so far.
Data Source=172.10.3.3;Initial Catalog=Elma;User ID=User11021969;Password=ILoveMyMOM;MultipleActiveResultSets=True;Min Pool Size=5;Max Pool Size=5000;Connect Timeout=180;Application Name=MonitoringSystem
I want to extract the Data Source 172.10.3.3 and save it as a string.