Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hiya, I have gone through the documentation for xml::simple, xml::libxml, xml::xpath and my head is still swimming. I want to do is parse the processed request and be able to use C0,C1,C2 as variables. For further understanding, it would be cool if you explain how to add the items to an array in the case of multiple results please? Thank you for your assistance.

My Code:
use XML::Simple; $xml = new XML::Simple; my $data = XMLin($xmlresult); print Dumper($data);

and the output for the dumper is:

$VAR1 = { 'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/', 's:Header' => { 'log' => { 'xmlns' => 'http://schemas.solarwinds +.com/2007/08/informationservice' } }, 's:Body' => { 'QueryXmlResponse' => { 'QueryXmlResult' => { 'query +Result' => { + 'template' => { + 'resultset' => { + 'column' => { + 'FriendlyName' => + { + + 'ordinal' => '2', + + 'type' => 'String' + } +, + 'AddressMask' => +{ + +'ordinal' => '1', + +'type' => 'String' + }, + 'SubnetAddress' = +> { + + 'type' => 'String', + + 'ordinal' => '0' + +} + } + } + }, + 'data' => { + 'row' => { + 'c2' => 'Extra Subnet', + 'c1' => '255.255.248.0', + 'c0' => '192.168.221.0' + } + }, + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance' + } }, 'xmlns' => 'http://schemas +.solarwinds.com/2007/08/informationservice' } } };

Replies are listed 'Best First'.
Re: XML for a newbie
by Athanasius (Archbishop) on Feb 10, 2016 at 07:31 UTC
Re: XML for a newbie
by Laurent_R (Canon) on Feb 10, 2016 at 07:35 UTC
    You probably don't want to use XML::Simple, whose usage is discouraged. Try XML::LibXML instead.

    Update: Oops, Athanasius has just provided a much more complete answer jus above while I was typing and posting under a very slow mobile network connection.

Re: XML for a newbie (SOAP)
by Anonymous Monk on Feb 10, 2016 at 07:27 UTC
Re: XML for a newbie
by crusty_collins (Friar) on Feb 10, 2016 at 14:52 UTC
    I think this is what you looking for. Its returning a hash ref. just deference it this way.
    my $C0 = $data->{'s:Body'}->{'QueryXmlResponse'}->{'QueryXmlResult'}-> +{'queryResult'}->{'data'}->{'row'}->{'c0'} print $C0;
    Result
    192.168.221.0
    "We can't all be happy, we can't all be rich, we can't all be lucky – and it would be so much less fun if we were. There must be the dark background to show up the bright colours." Jean Rhys (1890-1979)