I am trying to parse the following SOAP response using xPath and ElementTree but with no luck. I am not sure if this is the best way to do this? if it's not happy to hear other suggestions.
I have have cut down the XML to keep it readable.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:SelectCmDeviceResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://ccm.cisco.com/serviceability/soap/risport70/">
<SelectCmDeviceResult xsi:type="ns1:SelectCmDeviceResult">
<TotalDevicesFound xsi:type="xsd:unsignedInt">24</TotalDevicesFound>
<CmNodes soapenc:arrayType="ns1:CmNode[4]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<item xsi:type="ns1:CmNode">
<ReturnCode xsi:type="ns1:RisReturnCode">Ok</ReturnCode>
<Name xsi:type="xsd:string">uk-cucm-pub</Name>
<NoChange xsi:type="xsd:boolean">false</NoChange>
<CmDevices soapenc:arrayType="ns1:CmDevice[12]" xsi:type="soapenc:Array">
<item xsi:type="ns1:CmDevice">
<Name xsi:type="xsd:string">SIP-Trunk-to-NO-Cluster</Name>
<DirNumber xsi:type="xsd:string" xsi:nil="true"/>
<Class xsi:type="ns1:DeviceClass">SIP Trunk</Class>
<Model xsi:type="xsd:unsignedInt">131</Model>
<Status xsi:type="ns1:CmDevRegStat">Registered</Status>
What I like to achieve is to be able to go through each item
tag under the CmNodes
(only one item tag is shown above but there are multiple) and then under the CmDevices/item
if the Name
tag text is equal to SIP-Trunk-to-NO-Cluster then get the text under the Status
in this case this will be "Registered"
Thanks alexis