use warnings; use strict; use Data::Dumper; use XML::Simple; my $xmlin = <<XML; <?xml version = "1.0"?> <response> <custid>101010101</custid> <status>success</status> <responsecode>11</responsecode> <kf></kf> <cn>1111222233334444555</cn> <neta>7.00</neta> <prid>X111111111111111</prid> <ano>22222222</ano> <trxid>33333333</trxid> <description>Transfer Completed</description> </response> XML my $xml = XMLin($xmlin); print Dumper($xml); if ($xml->{status} eq 'success') { print 'yes' } else { print 'no' } __END__ $VAR1 = { 'kf' => {}, 'cn' => '1111222233334444555', 'status' => 'success', 'custid' => '101010101', 'neta' => '7.00', 'description' => 'Transfer Completed', 'trxid' => '33333333', 'ano' => '22222222', 'responsecode' => '11', 'prid' => 'X111111111111111' }; yes
By default, with your data, it returns a reference to a hash.
If your data is more complex than what you've shown, XML::Twig would be a better choice.
In reply to Re: parsing a simple xml response
by toolic
in thread parsing a simple xml response
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |