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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.