Monks,

I need to retrieve the contents of what I consider a complex soap response.The below response is a less complex one and returns a description element and the one line of code preceding it shows how I retrieve that value

my $_sDeviceDescription=$sEntireDeviceDescription->valueof('//return/row/description');
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/"> <soapenv:Body> <ns:executeSQLQueryResponse xmlns:ns="http://www.cisco.com/AXL/A +PI/8.5"> <return> <row> <description>TB3 - Test Phone - 20078</description> </row> </return> </ns:executeSQLQueryResponse> </soapenv:Body> </soapenv:Envelope>

Now, this is my more complex response. This query is done on Cisco Unified Communications Manager to get the registration status of a device(a phone). In CUCM there are many nodes to a cluster, and a phone can be registered to most of those nodes, that is why this query is done on all nodes and thus presents the results of each node for the same device. I need to return the value of the <Status> Element for those nodes that Have the <ReturnCode> element value of "Ok". To further explain, this(these) nodes are nodes where the phone is registered or was registered at one point. For the Nodes that have the <ReturnCode> value of "Ok" in this example, the value of <Status> is Unregistered, that is the value I would need to assign to a variable like in the less complex example above and later print that value. Thanks.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/"> <soapenv:Body> <ns1:selectCmDeviceResponse xmlns:ns1="http://schemas.cisco.com/ +ast/soap"> <ns1:selectCmDeviceReturn> <ns1:SelectCmDeviceResult> <ns1:TotalDevicesFound>2</ns1:TotalDevicesFound> <ns1:CmNodes> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.10</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.11</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.12</ns1:Name> <ns1:NoChange>true</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.13</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>Ok</ns1:ReturnCode> <ns1:Name>10.10.10.14</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices> <ns1:item> <ns1:Name>UPCTEST</ns1:Name> <ns1:DirNumber>20078-UnRegistered</ns1:DirN +umber> <ns1:DeviceClass>Phone</ns1:DeviceClass> <ns1:Model>503</ns1:Model> <ns1:Product>390</ns1:Product> <ns1:BoxProduct>0</ns1:BoxProduct> <ns1:Httpd>No</ns1:Httpd> <ns1:RegistrationAttempts>0</ns1:Registrati +onAttempts> <ns1:IsCtiControllable>true</ns1:IsCtiContr +ollable> <ns1:LoginUserId>sampleuser</ns1:LoginUserI +d> <ns1:Status>UnRegistered</ns1:Status> <ns1:StatusReason>8</ns1:StatusReason> <ns1:PerfMonObject>2</ns1:PerfMonObject> <ns1:DChannel>0</ns1:DChannel> <ns1:Description>TB3 - Test Phone - 20078</ +ns1:Description> <ns1:H323Trunk> <ns1:ConfigName xsi:nil="1" xmlns:xsi="h +ttp://www.w3.org/2001/XMLSchema-instance"/> <ns1:TechPrefix xsi:nil="1" xmlns:xsi="h +ttp://www.w3.org/2001/XMLSchema-instance"/> <ns1:Zone xsi:nil="1" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"/> <ns1:RemoteCmServer1 xsi:nil="1" xmlns:x +si="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:RemoteCmServer2 xsi:nil="1" xmlns:x +si="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:RemoteCmServer3 xsi:nil="1" xmlns:x +si="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:AltGkList xsi:nil="1" xmlns:xsi="ht +tp://www.w3.org/2001/XMLSchema-instance"/> <ns1:ActiveGk xsi:nil="1" xmlns:xsi="htt +p://www.w3.org/2001/XMLSchema-instance"/> <ns1:CallSignalAddr xsi:nil="1" xmlns:xs +i="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:RasAddr xsi:nil="1" xmlns:xsi="http +://www.w3.org/2001/XMLSchema-instance"/> </ns1:H323Trunk> <ns1:TimeStamp>1489800832</ns1:TimeStamp> <ns1:Protocol>SIP</ns1:Protocol> <ns1:NumOfLines>1</ns1:NumOfLines> <ns1:LinesStatus> <ns1:item> <ns1:DirectoryNumber>20078</ns1:Direc +toryNumber> <ns1:Status>UnRegistered</ns1:Status> </ns1:item> </ns1:LinesStatus> <ns1:ActiveLoadID>Jabber_for_Windows-11.8.2 +.50390</ns1:ActiveLoadID> <ns1:InactiveLoadID>Jabber_for_Windows-11.8 +.2.50390</ns1:InactiveLoadID> <ns1:DownloadStatus>Unknown</ns1:DownloadSt +atus> <ns1:DownloadFailureReason xsi:nil="1" xmln +s:xsi="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:DownloadServer xsi:nil="1" xmlns:xsi=" +http://www.w3.org/2001/XMLSchema-instance"/> <ns1:IPAddress> <ns1:item> <ns1:IP>10.171.39.29</ns1:IP> <ns1:IPAddrType>ipv4</ns1:IPAddrType> <ns1:Attribute>Unknown</ns1:Attribute +> </ns1:item> </ns1:IPAddress> </ns1:item> </ns1:CmDevices> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.15</ns1:Name> <ns1:NoChange>true</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.16</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>Ok</ns1:ReturnCode> <ns1:Name>10.10.10.17</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices> <ns1:item> <ns1:Name>UPCTEST</ns1:Name> <ns1:DirNumber>20078-UnRegistered</ns1:DirN +umber> <ns1:DeviceClass>Phone</ns1:DeviceClass> <ns1:Model>503</ns1:Model> <ns1:Product>390</ns1:Product> <ns1:BoxProduct>0</ns1:BoxProduct> <ns1:Httpd>No</ns1:Httpd> <ns1:RegistrationAttempts>0</ns1:Registrati +onAttempts> <ns1:IsCtiControllable>true</ns1:IsCtiContr +ollable> <ns1:LoginUserId>sampleuser</ns1:LoginUserI +d> <ns1:Status>UnRegistered</ns1:Status> <ns1:StatusReason>6</ns1:StatusReason> <ns1:PerfMonObject>2</ns1:PerfMonObject> <ns1:DChannel>0</ns1:DChannel> <ns1:Description>TB3 - Test Phone - 20078</ +ns1:Description> <ns1:H323Trunk> <ns1:ConfigName xsi:nil="1" xmlns:xsi="h +ttp://www.w3.org/2001/XMLSchema-instance"/> <ns1:TechPrefix xsi:nil="1" xmlns:xsi="h +ttp://www.w3.org/2001/XMLSchema-instance"/> <ns1:Zone xsi:nil="1" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"/> <ns1:RemoteCmServer1 xsi:nil="1" xmlns:x +si="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:RemoteCmServer2 xsi:nil="1" xmlns:x +si="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:RemoteCmServer3 xsi:nil="1" xmlns:x +si="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:AltGkList xsi:nil="1" xmlns:xsi="ht +tp://www.w3.org/2001/XMLSchema-instance"/> <ns1:ActiveGk xsi:nil="1" xmlns:xsi="htt +p://www.w3.org/2001/XMLSchema-instance"/> <ns1:CallSignalAddr xsi:nil="1" xmlns:xs +i="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:RasAddr xsi:nil="1" xmlns:xsi="http +://www.w3.org/2001/XMLSchema-instance"/> </ns1:H323Trunk> <ns1:TimeStamp>1489766440</ns1:TimeStamp> <ns1:Protocol>SIP</ns1:Protocol> <ns1:NumOfLines>1</ns1:NumOfLines> <ns1:LinesStatus> <ns1:item> <ns1:DirectoryNumber>20078</ns1:Direc +toryNumber> <ns1:Status>UnRegistered</ns1:Status> </ns1:item> </ns1:LinesStatus> <ns1:ActiveLoadID>Jabber_for_Windows-11.8.2 +.50390</ns1:ActiveLoadID> <ns1:InactiveLoadID>Jabber_for_Windows-11.8 +.2.50390</ns1:InactiveLoadID> <ns1:DownloadStatus>Unknown</ns1:DownloadSt +atus> <ns1:DownloadFailureReason xsi:nil="1" xmln +s:xsi="http://www.w3.org/2001/XMLSchema-instance"/> <ns1:DownloadServer xsi:nil="1" xmlns:xsi=" +http://www.w3.org/2001/XMLSchema-instance"/> <ns1:IPAddress> <ns1:item> <ns1:IP>10.171.39.29</ns1:IP> <ns1:IPAddrType>ipv4</ns1:IPAddrType> <ns1:Attribute>Unknown</ns1:Attribute +> </ns1:item> </ns1:IPAddress> </ns1:item> </ns1:CmDevices> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.18</ns1:Name> <ns1:NoChange>true</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.19</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.20</ns1:Name> <ns1:NoChange>false</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.21</ns1:Name> <ns1:NoChange>true</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.22</ns1:Name> <ns1:NoChange>true</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> <ns1:item> <ns1:ReturnCode>NotFound</ns1:ReturnCode> <ns1:Name>10.10.10.23</ns1:Name> <ns1:NoChange>true</ns1:NoChange> <ns1:CmDevices xsi:nil="1" xmlns:xsi="http://www. +w3.org/2001/XMLSchema-instance"/> </ns1:item> </ns1:CmNodes> </ns1:SelectCmDeviceResult> <ns1:StateInfo><![CDATA[<StateInfo><Node Name="10.10.10.10 +" SubsystemStartTime="1478227537" StateId="55886" TotalItemsFound="0" + TotalItemsReturned="0"/><Node Name="10.10.10.11" SubsystemStartTime= +"1478222504" StateId="131271" TotalItemsFound="0" TotalItemsReturned= +"0"/><Node Name="10.10.10.12" SubsystemStartTime="0" StateId="0" Tota +lItemsFound="0" TotalItemsReturned="0"/><Node Name="10.10.10.13" Subs +ystemStartTime="1478226627" StateId="101912" TotalItemsFound="0" Tota +lItemsReturned="0"/><Node Name="10.10.10.14" SubsystemStartTime="1478 +222406" StateId="37674" TotalItemsFound="1" TotalItemsReturned="1"/>< +Node Name="10.10.10.15" SubsystemStartTime="0" StateId="0" TotalItems +Found="0" TotalItemsReturned="0"/><Node Name="10.10.10.16" SubsystemS +tartTime="1478224422" StateId="19484" TotalItemsFound="0" TotalItemsR +eturned="0"/><Node Name="10.10.10.17" SubsystemStartTime="1478225730" + StateId="13357" TotalItemsFound="1" TotalItemsReturned="1"/><Node Na +me="10.10.10.18" SubsystemStartTime="0" StateId="0" TotalItemsFound=" +0" TotalItemsReturned="0"/><Node Name="10.10.10.19" SubsystemStartTim +e="1478222539" StateId="34839" TotalItemsFound="0" TotalItemsReturned +="0"/><Node Name="10.10.10.20" SubsystemStartTime="1478224147" StateI +d="1805" TotalItemsFound="0" TotalItemsReturned="0"/><Node Name="10.1 +0.10.21" SubsystemStartTime="0" StateId="0" TotalItemsFound="0" Total +ItemsReturned="0"/><Node Name="10.10.10.23" SubsystemStartTime="0" St +ateId="0" TotalItemsFound="0" TotalItemsReturned="0"/><Node Name="10. +10.10.22" SubsystemStartTime="0" StateId="0" TotalItemsFound="0" Tota +lItemsReturned="0"/></StateInfo>]]></ns1:StateInfo> </ns1:selectCmDeviceReturn> </ns1:selectCmDeviceResponse> </soapenv:Body> </soapenv:Envelope>

In reply to Retrieving Specific Contents of SOAP Response via SOAP::Lite by adamZ88

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.