Below is the very multi-layered XML I am using after being sent through Data Dumper:
$VAR1 = { 'client_system' => { 'Customer Care' => { 'business_area' => { 'XX Business Area' => { 'component' => [ { 'component_lib' => [ { 'class_set' => { 'XX Active Strategy 2' => { 'data_type' => '1', 'linked_characteristic_name' => 'ACLI-DAT +A.X9999-ACLI-4-MTH-AVG-UTIL', 'version' => '2.0', 'is_protected' => 'false', 'obj_info' => { 'XX Active Strategy 2' => { 'obj_revision' => '1', 'version' => '2.0', } }, 'base_class_set' => [ { 'interval' => { '500-899' => { 'outcome' => { '500-899' => { 'uniqueID' => '4', 'displayPosition' => '3' } }, 'range' => [ '500-899' ], 'is_Others' => [ 'false' ] }, 'low-199' => { 'outcome' => { 'low-199' => { 'uniqueID' => '2', 'displayPosition' => '1' } }, 'range' => [ 'low-199' ], 'is_Others' => [ 'false' ] }, 'Others' => { 'outcome' => { 'Others' => { 'uniqueID' => '1', 'displayPosition' => '214 +7483647' } }, 'is_Others' => [ 'true' ] }, '200-499' => { 'outcome' => { '200-499' => { 'uniqueID' => '3', 'displayPosition' => '2' } }, 'range' => [ '200-499' ], 'is_Others' => [ 'false' ] } } } ] } }, 'type' => 'class_set' } ] } ], 'analytics' => [ {} ] } }, 'signature' => 'XXXXCC', 'version' => '3.0', 'type' => 'Standalone', 'obj_info' => { 'Customer Care' => { 'obj_revision' => '-1', 'version' => '2.0', } } } }, 'version' => '2.1', 'buildNumber' => 'Version 1.3' };
I basically would have the class set name then want to print that along with the (four) interval ranges.
#!/usr/bin/perl use strict; use XML::Simple; use Data::Dumper; my $file = 'files/data.xml'; my $xs1 = XML::Simple->new(); my $doc = $xs1->XMLin($file, forcearray => 1); foreach my $key (keys (%{$doc->{client_system}})){ print $doc->{client_system}->{$key} . "\n"; print $doc->{client_system}->{$key}->{'business_area'} ? ; }
Basically need to traverse down this tree:
'client_system' => { 'Customer Care' => { 'business_area' => { 'XX Business Area' => { 'component' => [ { 'component_lib' => [ { 'class_set' => { 'XX Active Strategy 2' => { 'base_class_set' => [ { 'interval' => { '500-899' => { 'low-199' => { 'Others' => { '200-499' => {
Any help is appreciated.

In reply to XML::Simple Multi-Layered by eide

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.