I am trying to integrate a web service with my project. The web service returns an XML response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.tpg.ua/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getCitiesResponse>
<return xsi:type="xsd:string">
[
{
"cityTitle": "Тирана",
"countryId": "7",
"cityId": "2493",
"IATA": "TIA"
},
{
"cityTitle": "Ла-Романа",
"countryId": "48",
"cityId": "1280",
"IATA": "LRM"
},
{
"cityTitle": "Херсон",
"countryId": "145",
"cityId": "2719",
"IATA": "KHE"
},
{
"cityTitle": "Шарм",
"countryId": "49",
"cityId": "2851",
"IATA": "SSH"
}
]
</return>
</ns1:getCitiesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am trying to parse that response. I want to get the cityId and the countryId
XmlDocument listXML = new XmlDocument();
listXML.LoadXml(response);
string baseNode = @"return/";
XmlNode item1 = listXML.SelectSingleNode(baseNode + "countryId");
XmlNode item2 = listXML.SelectSingleNode(baseNode + "cityId");
string s = item1.InnerText.ToString();
string s1 = item2.InnerText.ToString();
But it is null; what should I do?