in reply to Retrieving Specific Contents of SOAP Response via SOAP::Lite

Try

#!perl use strict; use XML::LibXML; use XML::LibXML::XPathContext; my $dom = XML::LibXML->load_xml( location => 'phone.xml' ); my $xml = XML::LibXML::XPathContext->new($dom); $xml->registerNs('ns1','http://schemas.cisco.com/ast/soap'); my $xpath = "//ns1:CmNodes /ns1:item /ns1:ReturnCode[text() = 'Ok']"; my @nodes = $xml->findnodes($xpath); for my $node (@nodes){ my $name = $node->findvalue('../ns1:Name'); print $name."\n"; my @dev = $node->findnodes('../ns1:CmDevices/ns1:item'); for my $dev (@dev){ my $name = $dev->findvalue('ns1:Name'); my $status = $dev->findvalue('ns1:Status'); my $desc = $dev->findvalue('ns1:Description'); print " $name $status $desc\n"; } }
poj

Replies are listed 'Best First'.
Re^2: Retrieving Specific Contents of SOAP Response via SOAP::Lite
by adamZ88 (Beadle) on Mar 22, 2017 at 00:39 UTC

    Poj, as always, great explanation!! One single doubt, in the below what is the purpose of "'phone.xml'"

    my $dom = XML::LibXML->load_xml( location => 'phone.xml' );

      phone.xml was your soap message I put in a file. I guess you need to change that to

      my $dom = XML::LibXML->load_xml( string => $xml_string );
      

      See XML::LibXML::Parser

      poj