in reply to XML data extraction

Hello snehit.ar,

Is there any sample of code? Did you try something and did not work?

Are you getting an error on your code?

Update: When I execute your code including the line (print Dumper \@records) I am getting:

$VAR1 = [ { 'Time' => 'OK', 'name' => '3YP (421)', 'status' => '20', 'citype' => 'application' } ];

Based on your desired output the only difference that I see is the time. Is this what you are having problem retrieving?

Looking forward to your update. BR / Thanos

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: XML data extraction
by snehit.ar (Beadle) on Oct 11, 2017 at 11:43 UTC
    Sample code i Have share but it need updation base on given 2 condition for required output..Thank you for help.
    #!/usr/bin/perl use strict; use warnings; use XML::XPath; use XML::LibXML::NodeList; use Data::Dumper; my @records; my $bamxml = 'BAMOpenApi.xml'; my $bamxp = XML::XPath->new(filename => $bamxml); my $bamxpath = $bamxp->findnodes('//nodes/node/children/node/chil +dren/node'); my $pattern = shift; my $matches = XML::LibXML::NodeList->new; foreach my $bamnode ($bamxpath->get_nodelist) { my $name = $bamxp->find('./@name',$bamnode)->string_value; my $citype = $bamxp->find('./@ciType',$bamnode)->string_value; my $status = $bamxp->find('./dimension/@status',$bamnode)->str +ing_value; my $time = $bamxp->find("./dimension/body/entry",$bamnode)->st +ring_value; s/^\s+|\s+$//g for $name,$citype,$status,$time; push @records, { name => $name, citype => $citype, status => $status, Time => $time }; }