ktpmm5 has asked for the wisdom of the Perl Monks concerning the following question:
The section above repeats about 10 times per file (once for each host tested). I have successfully parsed the beginning section (getting the values of success, localTime, and portResponse) with the code below, but I can't figure out how to get to the 'snmpType' area, and put targetType, name and protocol into variables. Can someone help me to figure out what I need to do? thank you-'timeResult' => [ { 'success' => 'false', 'connection' => 'eth1', 'portResponse' => 'OK', 'ns5:snmpType' => { 'cd5:targetType' => 'eth', 'name' => 'string1', 'cd5:protocol' => 'udp', }, 'localTime' => '2008-12-04T' }
use XML::XPath; # ## create object my $xml = XML::XPath->new(filename => '/sources/sample.xml'); # foreach my $row ($xml->findnodes('/touchResult/scanResult')) { my $success = $row->find('success')->string_value; my $portResponse = $row->find('portResponse')->string_value; my $localTime = $row->find('localTime')->string_value; ....; }
|
|---|