Hi monks, This is very simple for experts but not for beginners like me.I have one xml file and I processed using XML::Simple like this
my $file="service.xml"; my $xml = new XML::Simple; my $data = $xml->XMLin("$file", ForceArray =>['Service','SystemReact +ion','Customers','Suppliers','SW','HW'],); print Dupmer ($data);
it printing hash of data like this
$var1={ 'Service' => [ { 'Suppliers' => [ { 'SW' => [ { 'Path' => '/work/service.xml', 'Service' => 'b7a' }, { 'Path' => '/work/service1.xml', 'Service' => 'b7b' }, { 'Path' => '/work/service2.xml', 'Service' => 'b5' } ] } ], 'Id' => 'SKRM', 'Customers' => [ { 'SW' => [ { 'Path' => '/work/service.xml', 'Service' => 'ASOC' } ] } ], 'Des' => 'Control the current through the pipe', 'Name' => ' Control unit' }, { 'Suppliers' => [ { 'HW' => [ { 'Type' => 'W', 'Path' => '/work/hardware.xml', 'Nr' => '18', 'Service' => '1' }, { 'Type' => 'B', 'Path' => '/work/hardware.xml', 'Nr' => '7', 'Service' => '1' }, { 'Type' => 'k', 'Path' => '/work/hardware.xml', 'Nr' => '1', 'Service' => '1' } ] } ], 'Id' => 'ADTM', 'Customers' => [ { 'SW' => [ { 'Path' => '/work/service.xml', 'Service' => 'SDCR' } ] } ], 'Des' => 'It delivers actual motor speed', 'Name' => ' Motor Drivers and Diognostics' }, ] 'Systemreaction'=>[ { ------- ------- ------- } { ------- ------- ------- }, ] };
How to access each elements in the service and systemReaction(not provided). because I am using "$data" in further processing. So I need to access each Id,customers, suppliers values in each service. How to get particular value from service to do some process with that value.for example I need to get all Id values form service and create nodes for each id values.
Thanks in advance
In reply to How to access hash of arrays values using perl by veerubiji
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |